/* ═══════════════════════════════════════════════════
   Progression Engine — Dark Focus Theme
   Alpha Progression-inspired: minimal, dark, strong
   ═══════════════════════════════════════════════════ */

:root {
    --bg-primary: #0D0D0D;
    --bg-surface: #1A1A1A;
    --bg-elevated: #242424;
    --bg-input: #2A2A2A;
    --accent: #4A9EFF;
    --accent-dim: #2A6BBF;
    --text-primary: #FFFFFF;
    --text-secondary: #8A8A8A;
    --text-muted: #8A8A8A; /* #555555; */
    --text-soft: #A5A5A5;
    --success: #4CAF50;
    --success-dim: #2E7D32;
    --warning: #FF9800;
    --error: #F44336;
    --border: #333333;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.15s ease;
}

/* ── Light Theme ── */
html[data-theme="light"] {
    --bg-primary:    #F5F5F5;
    --bg-surface:    #FFFFFF;
    --bg-elevated:   #EFEFEF;
    --bg-input:      #E8E8E8;
    --accent:        #1A6FD4;
    --accent-dim:    #1456A8;
    --text-primary:  #0D0D0D;
    --text-secondary:#555555;
    --text-muted:    #888888;
    --text-soft:     #707070;
    --success:       #2E7D32;
    --success-dim:   #1B5E20;
    --warning:       #E65100;
    --error:         #C62828;
    --border:        #DDDDDD;
}

/* ── High Contrast (stacks on either theme) ── */
html[data-accessibility~="high-contrast"] {
    --bg-primary:    #000000;
    --bg-surface:    #0A0A0A;
    --bg-elevated:   #111111;
    --bg-input:      #1A1A1A;
    --accent:        #FFFF00;
    --accent-dim:    #CCCC00;
    --text-primary:  #FFFFFF;
    --text-secondary:#DDDDDD;
    --text-muted:    #AAAAAA;
    --text-soft:     #CCCCCC;
    --border:        #FFFFFF;
}
html[data-theme="light"][data-accessibility~="high-contrast"] {
    --bg-primary:    #FFFFFF;
    --bg-surface:    #FFFFFF;
    --bg-elevated:   #F0F0F0;
    --bg-input:      #E0E0E0;
    --text-primary:  #000000;
    --text-secondary:#222222;
    --text-muted:    #444444;
    --text-soft:     #333333;
    --border:        #000000;
    --accent:        #0000CC;
    --accent-dim:    #0000AA;
}

/* ── Colorblind Friendly — red/green → orange/blue (deuteranopia/protanopia safe) ── */
html[data-accessibility~="colorblind"] {
    --success:       #0077BB;
    --success-dim:   #005588;
    --warning:       #FFB000;
    --error:         #EE7733;
}

/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow: hidden;
    height: 100%;
}

/* ── Safe Areas (iOS) ── */
.status-bar-safe-area {
    display: none;
}

@supports (-webkit-touch-callout: none) {
    .status-bar-safe-area {
        display: flex;
        position: sticky;
        top: 0;
        height: env(safe-area-inset-top);
        background-color: var(--bg-primary);
        width: 100%;
        z-index: 100;
    }

    .page-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ── Page Container ── */
.page-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    /* dvh, not vh: on mobile Safari 100vh is the *largest* viewport, so the scroller's
       bottom edge falls below the visible area and the last rows of a long page
       (e.g. the template form's Save button) can never be scrolled into view.
       vh first as a fallback for engines without dvh. */
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    scrollbar-width: none;
}
.page-container::-webkit-scrollbar { display: none; }

/* ── Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.back-btn {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background var(--transition);
}

.back-btn:active {
    background: var(--border);
}

/* ── Exercise Card (List View) ── */
.exercise-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.exercise-card:active {
    background: var(--bg-elevated);
    transform: scale(0.98);
}

.exercise-card.completed {
    border-color: var(--success-dim);
}

.exercise-card.completed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--success);
}

.exercise-card.flagged {
    border-color: var(--warning);
}

.exercise-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.exercise-meta {
    display: flex;
    gap: 16px;
    align-items: center;
}

.lift-class-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: rgba(74, 158, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.prescription {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 10px 0 6px;
}

.prescription-unit {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.previous-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 8px;
}

.previous-sets {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.previous-set {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
}

.stall-badge {
    font-size: 0.75rem;
    color: var(--warning);
    margin-top: 6px;
}

/* ── Set Logger (Exercise Detail View) ── */
.set-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.set-swipe-wrapper {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
}

/* Swipeable rows: vertical panning stays native, horizontal is handed to registerSetSwipes.
   Without this WKWebView claims the gesture for itself and fires pointercancel a few px in,
   which snaps the row back mid-swipe. Long-press selection/callout is off so a slow drag
   doesn't turn into a text selection on iOS. */
.set-swipe-wrapper.is-logged,
.set-swipe-wrapper.is-swipeable {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* WebKit dispatches no pointer events from a disabled control, so a logged row's locked
   inputs would swallow the swipe. Let the touch fall through to the row instead. */
.set-swipe-wrapper .set-input:disabled {
    pointer-events: none;
}

.set-delete-bg {
    position: absolute;
    inset: 0;
    background: #dc3545;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 22px;
    border-radius: var(--radius);
    color: #fff;
}

.set-delete-bg svg {
    width: 22px;
    height: 22px;
}

.set-row-inner {
    position: relative;
    z-index: 1;
    will-change: transform;
    background: var(--bg-surface);
    border-radius: var(--radius);
    overflow: hidden;
}

/* In swipe wrappers the border lives on set-row-inner so overflow:hidden doesn't clip corners */
.set-swipe-wrapper .set-row-inner {
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}
.set-swipe-wrapper .set-row-inner:has(.set-row.active),
.set-swipe-wrapper .set-row-inner:has(.set-row.editing) {
    border-color: var(--accent);
}
.set-swipe-wrapper .set-row-inner:has(.set-row.logged) {
    border-color: var(--success-dim);
}
.set-swipe-wrapper .set-row-inner:has(.set-row.warm-up-row) {
    border-color: rgba(220, 53, 69, 0.55);
}
.set-swipe-wrapper .set-row-inner:has(.set-row.warm-up-row.logged) {
    border-color: rgba(220, 53, 69, 0.75);
}

.set-swipe-wrapper .set-row {
    border-radius: 0;
    border: none;
    background: transparent;
}

.set-row {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 40px 1fr 1fr 56px;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}

.set-row.logged {
    border-color: var(--success-dim);
    background: rgba(76, 175, 80, 0.05);
}

.set-row.active {
    border-color: var(--accent);
}

.set-row.bonus {
    border-style: dashed;
    opacity: 0.85;
}

.add-set-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.add-set-btn:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.82);
}

/* ── Warm-up sets ── */
.warmup-label {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.62);
    margin-top: 12px;
    margin-bottom: 4px;
}

.warmup-set-list {
    margin-bottom: 0;
}

.set-row.warm-up-row {
    background: rgba(220, 53, 69, 0.08);
    border-color: rgba(220, 53, 69, 0.55);
}

.set-row.warm-up-row .set-number {
    color: rgba(220, 53, 69, 0.9);
}

.set-row.warm-up-row.logged {
    border-color: rgba(220, 53, 69, 0.75);
}

.set-row.warm-up-row .set-input {
    border: 1px solid rgba(220, 53, 69, 0.6);
    outline-color: rgba(220, 53, 69, 0.9);
}

.set-row.warm-up-row .set-input:focus {
    border-color: rgba(220, 53, 69, 0.95);
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.set-row.warm-up-row .confirm-btn {
    color: rgba(220, 53, 69, 0.95);
    border-color: rgba(220, 53, 69, 0.7);
}

.set-row.warm-up-row .confirm-btn.confirmed {
    background: rgba(220, 53, 69, 0.85);
    color: #fff;
    border-color: rgba(220, 53, 69, 1);
}

.set-row.warm-up-row .confirm-btn.editing {
    background: rgba(220, 53, 69, 0.35);
    color: #fff;
}

.add-warmup-btn {
    width: 100%;
    margin-top: 6px;
    margin-bottom: 10px;
    padding: 8px;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.add-warmup-btn:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.72);
}

/* ── Exercise note ── */
.note-ellipsis-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(74, 158, 255, 0.18);
    border: 1.5px solid var(--accent);
    color: var(--accent);
    font-size: 1rem;
    cursor: pointer;
    padding: 0;
    margin-left: 6px;
    overflow: hidden;
    transition: background 0.15s;
}

.note-ellipsis-btn:hover {
    background: rgba(74, 158, 255, 0.32);
}

.exercise-note-display {
    margin-top: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--text-muted);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.note-lock-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    line-height: 1.4;
    height: 1.4em;
}

.note-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-popup {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    padding: 20px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-popup-title {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    text-transform: uppercase;
}

.note-popup-input {
    width: 100%;
    min-height: 90px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 10px;
    resize: vertical;
    box-sizing: border-box;
}

.note-popup-input:focus {
    outline: none;
    border-color: var(--accent);
}

.note-char-count {
    font-size: 0.72rem;
    color: var(--text-soft);
    text-align: right;
    margin-top: -8px;
}

.note-popup-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-soft);
    cursor: pointer;
}

.note-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.note-popup-btn {
    padding: 8px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all var(--transition);
}

.note-popup-btn.cancel {
    background: transparent;
    color: var(--text-muted);
}

.note-popup-btn.save {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.note-popup-btn:hover {
    opacity: 0.85;
}

.exercise-action-menu {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    padding: 16px;
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-action-item {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--bg-surface);
    color: var(--text-primary);
    text-align: left;
    transition: all var(--transition);
}

.exercise-action-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.2);
}

.exercise-action-item.danger {
    color: var(--danger, #e05252);
    border-color: rgba(224, 82, 82, 0.4);
}

.exercise-action-item.danger:hover {
    background: rgba(224, 82, 82, 0.1);
}

.exercise-action-item.cancel {
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

.set-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-soft);
    text-align: center;
}

.set-number span {
    display: block;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.set-input-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.set-input-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.set-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    padding: 8px 10px;
    width: 100%;
    text-align: center;
    outline: none;
    transition: border-color var(--transition);
    -moz-appearance: textfield;
}

.set-input::-webkit-outer-spin-button,
.set-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.set-input:focus {
    border-color: var(--accent);
}

.set-input.logged {
    background: rgba(76, 175, 80, 0.1);
    border-color: var(--success-dim);
}

/* ── Confirm Button (Quick Tap) ── */
.confirm-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.confirm-btn:active {
    transform: scale(0.92);
}

.confirm-btn.confirmed {
    background: var(--success);
    border-color: var(--success);
    color: white;
    cursor: pointer;
}

.confirm-btn.confirmed:hover {
    opacity: 0.8;
}

/* Active edit state — blue, indicates unsaved changes */
.confirm-btn.editing {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    animation: pulse-edit 1.2s ease-in-out infinite;
}

@keyframes pulse-edit {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

/* Unlock the set-row border when editing */
.set-row.editing {
    border-color: var(--accent);
}

.confirm-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ── Previous Set Comparison ── */
/* Centered label with prev value: "WEIGHT · 185" */
.set-label-centered {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    text-align: center;
    margin-bottom: 2px;
}

/* ── Rest Timer (Bottom Bar Style) ── */
.rest-timer-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1000;
    padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    animation: timer-slide-up 0.3s ease-out;
}

@keyframes timer-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Main timer row: [−] [counter/skip] [+] */
.timer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 20px;
}

.timer-adjust-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    line-height: 1;
}

.timer-adjust-btn:active {
    background: var(--border);
    transform: scale(0.9);
}

.timer-adjust-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.timer-center-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 24px;
    border-radius: var(--radius);
    min-width: 110px;
    transition: background var(--transition);
}

.timer-center-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.timer-center-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.97);
}

.timer-time-value {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text-primary);
}

.timer-skip-label {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.timer-done {
    animation: pulse-glow 1s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from { color: var(--accent); }
    to { color: var(--success); text-shadow: 0 0 20px rgba(76, 175, 80, 0.5); }
}

/* ── Set Timer (timed-set full-screen countdown) ── */
.set-timer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 24px calc(24px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
    animation: timer-fade-in 0.2s ease-out;
}

@keyframes timer-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.set-timer-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 40px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    min-width: 240px;
}

.set-timer-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.set-timer-subtitle {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.set-timer-value {
    font-size: 4.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: var(--text-primary);
    margin: 8px 0;
}

.set-timer-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.set-timer-btn {
    flex: 1;
    padding: 14px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.set-timer-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.set-timer-btn:active {
    transform: scale(0.97);
}

.confirm-btn.timer-start {
    background: var(--accent);
    color: white;
    font-size: 1rem;
}

/* ── Complete Workout Button ── */
.complete-workout-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    transition: all var(--transition);
}

.complete-workout-btn:active {
    background: var(--accent-dim);
    transform: scale(0.98);
}

.complete-workout-btn:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Outlined variant, so a secondary action can sit above Done without competing with it */
.complete-workout-btn.secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 14px;
    margin-top: 20px;
}

.complete-workout-btn.secondary:active {
    background: var(--bg-elevated);
}

/* ── Results Summary ── */
.results-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.results-card .note {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 8px;
}

.results-card .next-target {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 8px;
}

/* ── Utility ── */
.mt-auto { margin-top: auto; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Blazor Error UI ── */
#blazor-error-ui {
    background: var(--error);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: var(--error);
    padding: 1rem;
    color: white;
    border-radius: var(--radius);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ═══════════════════════════════════════════════════
   Bottom Tab Bar
   ═══════════════════════════════════════════════════ */

.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 500;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;  /* anchors .tab-badge */
}

.tab-item.active {
    color: var(--accent);
}

.tab-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
}

.tab-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Page container adjustments for tab bar */
.page-container.has-tab-bar {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px);
}

.page-container.no-tab-bar {
    padding-bottom: 16px;
}

/* ═══════════════════════════════════════════════════
   Home Page
   ═══════════════════════════════════════════════════ */

.target-areas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.target-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: rgba(74, 158, 255, 0.12);
    padding: 4px 12px;
    border-radius: 20px;
}

.home-exercise-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.home-exercise-row {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 14px 16px;
    border: 1px solid var(--border);
}

.next-session-card {
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* What is next in the program: Home's next-session card (Scheduled only) and the post-session summary. */
.schedule-banner {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.schedule-banner.done {
    color: var(--success);
}

.next-session-card > .page-header,
.next-session-card > .target-areas,
.next-session-card > .home-exercise-list,
.next-session-card > .start-workout-btn {
    margin: 0;
}

.home-exercise-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.home-exercise-name {
    font-size: 1rem;
    font-weight: 600;
}

.home-exercise-prescription {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 4px 0;
}

.home-exercise-previous {
    font-size: 0.8rem;
    color: var(--text-soft);
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.start-workout-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
}

.start-workout-btn:active {
    background: var(--accent-dim);
    transform: scale(0.98);
}

.freestyle-workout-btn {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
    margin-top: 24px;
    margin-bottom: 24px;
}

.freestyle-workout-btn:hover {
    background: rgba(74, 158, 255, 0.08);
}

.freestyle-workout-btn:active {
    background: rgba(74, 158, 255, 0.16);
    transform: scale(0.98);
}

/* ═══════════════════════════════════════════════════
   Workout Flow — Top Bar (Exit + Elapsed Timer)
   ═══════════════════════════════════════════════════ */

.workout-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-primary);
    /* The exercise slides are GPU-composited (will-change: transform, opacity). Those layers
       can paint OVER this bar despite the higher z-index, so the opaque background alone
       doesn't hide content scrolling underneath. Promote the bar to its own compositing layer
       + isolate its stacking context so it always wins. No position:fixed descendants live
       here, so becoming their containing block is moot. */
    transform: translateZ(0);
    isolation: isolate;
}

/* All top-bar controls share the row equally; fixed widths are overridden so
   hidden buttons (LIST with no slots, ADD on preset templates) just let the rest stretch. */
.workout-top-bar > * {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
}

.exit-workout-btn {
    padding: 0;
    width: 70px;
    height: 36px;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition);
}

.exit-workout-btn:active {
    background: var(--bg-elevated);
    transform: scale(0.95);
}

.exit-workout-btn.danger {
    background: transparent;
    border-color: #e74c3c;
    color: var(--text-muted);
}

.exit-workout-btn.danger:active {
    background: rgba(231, 76, 60, 0.12);
}

.exit-workout-btn.accent {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}

.exit-workout-btn.accent:active {
    background: rgba(74, 158, 255, 0.12);
}

.elapsed-time-box {
    width: 105px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    padding: 0;
    transition: all var(--transition);
}

.elapsed-time-box:active {
    transform: scale(0.96);
}

.elapsed-time-box.paused {
    border-color: var(--accent);
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════
   Workout Flow — Exit Prompt Modal
   ═══════════════════════════════════════════════════ */

.exit-prompt-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.exit-prompt-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exit-prompt-title {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
}

.exit-prompt-subtitle {
    font-size: 0.85rem;
    color: var(--text-soft);
    text-align: center;
    margin-bottom: 4px;
}

.exit-prompt-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

.exit-prompt-btn.save {
    background: var(--accent);
    color: var(--text-primary);
}

.exit-prompt-btn.discard {
    background: var(--bg-elevated);
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

.exit-prompt-btn.cancel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.exit-prompt-btn:active {
    transform: scale(0.97);
}

.exit-prompt-btn:disabled {
    opacity: 0.5;
}

/* ═══════════════════════════════════════════════════
   Workout Flow — Progress Dots
   ═══════════════════════════════════════════════════ */

.workout-progress-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0 16px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.progress-dot.done {
    background: var(--success);
    border-color: var(--success);
}

.progress-dot.current {
    background: var(--accent);
    border-color: var(--accent);
    width: 10px;
    height: 10px;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════
   Workout Flow — Slide-Up Card Stack
   ═══════════════════════════════════════════════════ */

/* Fills the page-container so the workout screen never scrolls at the page level. The top bar
   and progress dots are fixed-size; the stack (or collapsed list / empty state) flexes to fill
   the rest and does all scrolling internally. Replaces a fragile 100vh magic height that, inside
   the 100dvh container, overflowed on mobile and let the page scroll the header behind
   the pinned top bar. */
.workout-flow-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.workout-flow-shell > .workout-top-bar,
.workout-flow-shell > .workout-progress-bar {
    flex: 0 0 auto;
}

.exercise-stack {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.exercise-slide {
    position: absolute;
    /* top:0 + bottom:0 sizes the slide from the stack's insets rather than height:100%, so it
       fills the flex-sized stack without relying on percentage-height resolution inside a flex
       item. translateY(±100%) for completed/upcoming still resolves against this used height. */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s ease;
    will-change: transform, opacity;
    overflow-y: auto;
    overscroll-behavior: contain; /* don't chain-scroll the page (would push the top bar away) */
    padding: 0 0 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE / Edge */
}
.exercise-slide::-webkit-scrollbar { display: none; } /* Chrome / Safari / WebView */

.exercise-slide.completed {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.exercise-slide.current {
    /* transform: none (not translateY(0)) and no will-change: a transformed/will-change
       ancestor becomes the containing block for position:fixed, which pinned the
       SupersetCard's rest-timer bar mid-screen instead of to the viewport bottom. */
    transform: none;
    will-change: auto;
    opacity: 1;
}

.exercise-slide.upcoming {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.exercise-stack.is-hidden { display: none; }

/* ── Collapse-all: compact exercise list ── */
.exit-workout-btn.collapse-toggle {
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.exercise-collapsed-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.exercise-collapsed-list::-webkit-scrollbar { display: none; }

.collapsed-exercise-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}

/* Press feedback sits on the tappable part, not the row — on the row it would fight
   the translateY the reorder handler writes while dragging. */
.collapsed-row-main:active {
    transform: scale(0.99);
}

/* Transparent button carrying tap-to-expand. The row is now grip + this. */
.collapsed-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform var(--transition);
}

/* ═══ Drag-to-reorder grip (in-session LIST) ═══ */

.drag-handle {
    flex-shrink: 0;
    /* Negative margin buys vertical touch area without growing the row. */
    padding: 6px 10px 6px 0;
    margin: -6px 0;
    color: var(--text-soft);
    font-size: 1.05rem;
    line-height: 1;
    cursor: grab;
    /* Claim the vertical gesture on the grip only — the list must keep scrolling. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.drag-handle:active { cursor: grabbing; }

.collapsed-exercise-row.is-dragging {
    /* Track the finger 1:1 — the row's `transition: all` would otherwise lag it. */
    transition: none;
    position: relative;
    z-index: 2;
    box-shadow: 0 8px 20px rgb(0 0 0 / 35%);
}

/* Kill selection and the iOS long-press callout for the duration of the drag. */
.exercise-collapsed-list.is-reordering,
.exercise-collapsed-list.is-reordering .collapsed-exercise-row {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.collapsed-exercise-row.active {
    border: 2px solid var(--success);
}

.collapsed-exercise-row.done {
    opacity: 0.65;
}

.collapsed-row-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collapsed-row-progress {
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.collapsed-row-check {
    color: var(--accent);
    letter-spacing: 0.05em;
}

/* Exercise card header within slide */
.exercise-card-header {
    margin-bottom: 16px;
}

/* Pin the single-exercise header (title, prescription line, notes) to the top of the
   scrolling slide so it stays visible while the user scrolls through the sets.
   The 16px divider gap is moved from margin into padding so the opaque background covers
   the full band — warm-up and working rows slide fully behind it, never peeking through. */
.exercise-slide > .exercise-card-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-primary);
    margin-bottom: 0;
    padding-bottom: 16px;
}

/* Superset: pin EACH exercise's header the same way. Each header's sticky containing block is
   its own .superset-exercise-outline, so the two never fight over top:0 — A's header pins only
   while A's outline is on screen, then B's takes over as B's outline scrolls up under it. Paired
   with scrollToNextActiveSet landing the active row just below the active exercise's header, this
   gives supersets the same top-pinned title as a single exercise. Opaque background (inset by the
   outline's side padding, which matches the rows' inset) hides rows sliding behind it. */
.superset-exercise-outline > .exercise-card-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-primary);
    margin-bottom: 0;
    padding-bottom: 16px;
}

/* ═══════════════════════════════════════════════════
   Profile — Settings + Equipment
   ═══════════════════════════════════════════════════ */

.profile-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    margin-top: 16px;
}

.profile-section-subtitle {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 12px;
}

.profile-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.profile-setting-name {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.profile-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.85rem;
}

.profile-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.profile-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.profile-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.profile-toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}

.profile-toggle input:checked + .profile-toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.profile-toggle input:checked + .profile-toggle-slider::before {
    transform: translateX(22px);
    background: var(--text-primary);
}

.profile-equip-action {
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.profile-equip-action:active {
    background: var(--border);
    transform: scale(0.95);
}

.profile-equip-category {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-top: 12px;
    margin-bottom: 4px;
}

.profile-equip-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

.profile-equip-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Profile Header ── */

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0 20px;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-header-info {
    min-width: 0;
}

.profile-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-since {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-top: 3px;
}

/* ── Profile Stats Strip ── */

.profile-stats-strip {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 4px;
}

.profile-stat-cell {
    flex: 1;
    text-align: center;
    padding: 14px 8px;
}

.profile-stat-cell + .profile-stat-cell {
    border-left: 1px solid var(--border);
}

.profile-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-stat-label {
    font-size: 0.65rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
}

/* ── Profile Setting Sub-label ── */

.profile-setting-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── App Info Footer ── */

.profile-app-info {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-soft);
    padding: 32px 0 16px;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════
   Coaching Dialog — Post-session AI debrief
   ═══════════════════════════════════════════════════ */

.coaching-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}

.coaching-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
    overflow: hidden;
}

.coaching-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.coaching-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.coaching-skip-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.coaching-skip-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.coaching-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.coaching-msg {
    display: flex;
}

.coaching-msg.coach {
    justify-content: flex-start;
}

.coaching-msg.user {
    justify-content: flex-end;
}

.coaching-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.coaching-msg.coach .coaching-bubble {
    background: var(--success);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.coaching-msg.user .coaching-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator dots */
.coaching-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 18px;
}

.coaching-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: coaching-dot-pulse 1.2s ease-in-out infinite;
}

.coaching-typing span:nth-child(2) { animation-delay: 0.2s; }
.coaching-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes coaching-dot-pulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.9); }
    30%            { opacity: 1;   transform: scale(1.1); }
}

.coaching-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 0 8px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.coaching-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    padding: 12px 14px;
    outline: none;
    transition: border-color var(--transition);
    user-select: text;
}

.coaching-input:focus {
    border-color: var(--accent);
}

.coaching-input:disabled {
    opacity: 0.5;
}

.coaching-send-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}

.coaching-send-btn:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: default;
}

.coaching-done-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--success);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin: 8px 0 12px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.coaching-done-btn:disabled {
    background: var(--success-dim);
    cursor: default;
}

/* ═══════════════════════════════════════════════════
   Workouts Tab — Templates & Programs
   ═══════════════════════════════════════════════════ */

.program-banner {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color var(--transition);
    margin-bottom: 4px;
}

.program-banner:hover {
    border-color: var(--accent);
}

.program-banner-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 4px;
}

.program-banner-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.program-banner-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.template-action-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}

.template-action-btn:hover {
    background: rgba(74, 158, 255, 0.1);
}

.template-action-btn.secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}

.template-action-btn.secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.template-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    margin: 20px 0 10px;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.template-card:hover {
    border-color: var(--accent-dim);
}

.template-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.template-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.template-card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.template-card-meta {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-top: 6px;
}

.template-card-areas {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.template-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.template-start-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
}

.template-start-btn:hover {
    background: var(--accent-dim);
}

.template-edit-btn {
    min-width: 110px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.template-edit-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.enrolled-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--success);
    background: rgba(76, 175, 80, 0.15);
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════
   Program Detail — Day Schedule
   ═══════════════════════════════════════════════════ */

.program-day-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.program-day-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: border-color var(--transition);
}

.program-day-row.current-day {
    border-color: var(--accent);
    background: rgba(74, 158, 255, 0.05);
}

.program-day-row.rest-day {
    opacity: 0.6;
}

.program-day-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.program-day-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    min-width: 48px;
}

.program-day-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.program-day-name.rest {
    color: var(--text-soft);
    font-style: italic;
}

.program-day-exercises {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-left: 58px;
}

.program-day-exercise {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 2px 10px;
    border-radius: 12px;
}

/* ═══════════════════════════════════════════════════
   Template Create / Edit
   ═══════════════════════════════════════════════════ */

.template-form-field {
    margin-bottom: 16px;
}

.template-form-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

.template-form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    padding: 12px 14px;
    outline: none;
    transition: border-color var(--transition);
    user-select: text;
}

.template-form-input:focus {
    border-color: var(--accent);
}

.template-exercise-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.template-exercise-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.template-exercise-config {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template-config-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 60px;
}

.template-config-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
}

.template-config-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 10px;
    outline: none;
    width: 100%;
    text-align: center;
    transition: border-color var(--transition);
}

.template-config-input:focus {
    border-color: var(--accent);
}
.template-config-input::-webkit-outer-spin-button,
.template-config-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.template-config-input[type=number] { -moz-appearance: textfield; }

.template-config-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 8px 6px;
    outline: none;
    width: 100%;
    text-align: center;
    transition: border-color var(--transition);
    cursor: pointer;
}

.template-config-select:focus {
    border-color: var(--accent);
}

.progression-scheme-row {
    display: flex;
    align-items: center;
    margin-top: 8px;
}

.progression-scheme-selector {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.progression-scheme-btn {
    flex: 1;
    background: none;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 14px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.progression-scheme-btn:last-child {
    border-right: none;
}

.progression-scheme-btn:hover {
    background: rgba(74, 158, 255, 0.08);
    color: var(--text-secondary);
}

.progression-scheme-btn.active {
    background: rgba(74, 158, 255, 0.18);
    color: var(--accent);
}

.template-remove-btn {
    background: none;
    border: none;
    color: var(--error);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.template-remove-btn:hover {
    opacity: 1;
}

.template-save-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--success);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    transition: background var(--transition);
}

.template-form-actions {
    position: sticky;
    bottom: calc(-16px - env(safe-area-inset-bottom, 0px));
    z-index: 20;
    display: flex;
    gap: 8px;
    margin: 16px -16px 0;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}

.template-form-cancel-btn {
    flex: 1;
    padding: 16px;
}

/* Doubled class so this beats .template-save-btn's margin-top regardless of rule order. */
.template-save-btn.template-form-save-btn {
    flex: 2;
    margin-top: 0;
}

.template-save-btn:disabled {
    background: var(--success-dim);
    cursor: default;
}

/* ═══════════════════════════════════════════════════
   Exercise Picker Modal
   ═══════════════════════════════════════════════════ */

.picker-overlay {
    position: fixed;
    inset: 0;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, 0.7);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.picker-sheet {
    background: var(--bg-primary);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.picker-title {
    font-size: 1rem;
    font-weight: 700;
}

.picker-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.picker-search {
    margin: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    padding: 10px 14px;
    outline: none;
    flex-shrink: 0;
}

.picker-search:focus {
    border-color: var(--accent);
}

.picker-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.picker-item:hover {
    background: var(--bg-elevated);
}

.picker-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.picker-item-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.picker-custom-badge {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid rgba(74, 158, 255, 0.35);
    border-radius: 4px;
    padding: 2px 5px;
}

.picker-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    padding: 10px 16px 6px;
    border-bottom: 1px solid var(--border);
}

.picker-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.picker-create-btn {
    margin: 12px 16px 16px;
    padding: 12px;
    background: transparent;
    color: var(--accent);
    border: 1px dashed var(--accent);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.picker-create-btn:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.picker-back {
    background: transparent;
    border: 0;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 8px;
}

.picker-create-form {
    padding: 12px 16px 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.picker-create-submit {
    margin-top: 16px;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.picker-create-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Freestyle save-as-template dialog actions */
.freestyle-save-actions {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: 20px;
}

.freestyle-save-btn {
    flex: 1;
    height: 48px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.freestyle-save-btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.freestyle-save-btn.danger {
    background: transparent;
    color: #e74c3c;
    border-color: #e74c3c;
}

.freestyle-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.freestyle-save-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.picker-create-error {
    margin-top: 10px;
    color: #e74c3c;
    font-size: 0.85rem;
}

.picker-create-hint {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-soft);
    text-align: center;
}

/* ── Exercise List Page ── */

.exercise-new-btn {
    background: none;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.exercise-new-btn:hover {
    background: rgba(74, 158, 255, 0.1);
}

.exercise-empty-state {
    /* display is toggled inline (flex/none); when shown it fills the shell's leftover space
       so the add button sits centered rather than clinging to the top. */
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-soft);
}

.exercise-empty-add-btn {
    padding: 14px 32px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
}

.exercise-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.exercise-empty-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.exercise-empty-sub {
    font-size: 0.85rem;
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 24px;
}

.exercise-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.exercise-list-info {
    flex: 1;
    min-width: 0;
}

.exercise-list-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exercise-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.exercise-equip-count {
    font-size: 0.75rem;
    color: var(--text-soft);
}

.exercise-list-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.exercise-action-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius);
    padding: 5px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.exercise-action-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.exercise-action-btn.danger {
    border-color: rgba(255, 80, 80, 0.4);
    color: #ff6464;
}

.exercise-action-btn.danger:hover {
    border-color: #ff6464;
    color: #ff8080;
}

.exercise-action-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.exercise-delete-confirm {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 4px;
}

.exercise-delete-prompt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.exercise-delete-prompt strong {
    color: var(--text-primary);
}

.exercise-delete-btns {
    display: flex;
    gap: 8px;
}

.exercise-delete-error {
    font-size: 0.85rem;
    color: #ff6464;
    line-height: 1.5;
}

/* ── Exercise Form Page ── */

.liftclass-selector {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.liftclass-btn {
    flex: 1;
    background: none;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 10px 4px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-align: center;
}

.liftclass-btn:last-child {
    border-right: none;
}

.liftclass-btn:hover {
    background: rgba(74, 158, 255, 0.08);
    color: var(--text-secondary);
}

.liftclass-btn.active {
    background: rgba(74, 158, 255, 0.18);
    color: var(--accent);
}

.exercise-form-error {
    background: rgba(255, 80, 80, 0.08);
    border: 1px solid rgba(255, 80, 80, 0.3);
    border-radius: var(--radius);
    color: #ff6464;
    font-size: 0.85rem;
    padding: 10px 14px;
    margin-bottom: 8px;
}

/* ── Collapse Tree (Exercise Form) ── */

.collapse-tree {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.collapse-section-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    user-select: none;
    transition: background var(--transition);
}

.collapse-section-row:last-child {
    border-bottom: none;
}

.collapse-section-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.collapse-section-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.collapse-section-summary {
    font-size: 0.78rem;
    color: #ffaa40;
    margin-left: 2px;
}

.collapse-cat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 32px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    user-select: none;
    transition: background var(--transition);
}

.collapse-cat-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.collapse-cat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.collapse-cat-count {
    font-size: 0.72rem;
    color: #ffaa40;
    margin-left: 2px;
}

.collapse-items {
    padding: 6px 16px 10px 48px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.collapse-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.collapse-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
}

.collapse-icon {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-soft);
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Program Builder ── */

.program-builder-empty {
    font-size: 0.85rem;
    color: var(--text-soft);
    padding: 14px 0 8px;
    font-style: italic;
}

.program-day-builder-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.program-day-builder-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-soft);
    min-width: 22px;
    text-align: right;
    flex-shrink: 0;
}

.program-day-type-selector {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.program-day-type-btn {
    background: none;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.program-day-type-btn:last-child {
    border-right: none;
}

.program-day-type-btn.active.training {
    background: rgba(74, 158, 255, 0.18);
    color: var(--accent);
}

.program-day-type-btn.active.rest {
    background: rgba(140, 140, 160, 0.15);
    color: var(--text-secondary);
}

.program-day-template-select {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 7px 10px;
    outline: none;
    min-width: 0;
    transition: border-color var(--transition);
    cursor: pointer;
}

.program-day-template-select:focus {
    border-color: var(--accent);
}

.program-day-rest-label {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-soft);
    font-style: italic;
    padding-left: 4px;
}

.program-day-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.program-day-remove-btn:hover {
    color: #ff6464;
}

.program-builder-add-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.program-builder-add-btn {
    flex: 1;
    background: none;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
    transition: background var(--transition);
}

.program-builder-add-btn.training {
    border: 1.5px dashed var(--accent);
    color: var(--accent);
}

.program-builder-add-btn.training:hover {
    background: rgba(74, 158, 255, 0.08);
}

.program-builder-add-btn.rest {
    border: 1.5px dashed var(--border);
    color: var(--text-muted);
}

.program-builder-add-btn.rest:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ── Muscle Tags ── */

.muscle-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.muscle-tag.primary {
    background: rgba(255, 160, 60, 0.15);
    color: #ffaa40;
    border: 1px solid rgba(255, 160, 60, 0.3);
}

.muscle-tag.secondary {
    background: rgba(140, 140, 160, 0.12);
    color: var(--text-soft);
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════
   Progress Tab
   ═══════════════════════════════════════════════════ */

.progress-exercise-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-exercise-row:active {
    background: var(--bg-elevated);
    border-color: var(--accent-dim);
}

.progress-exercise-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.progress-exercise-meta {
    font-size: 0.78rem;
    color: var(--text-soft);
}

.progress-exercise-chevron {
    font-size: 1.2rem;
    color: var(--text-soft);
    margin-left: 10px;
    flex-shrink: 0;
}

.progress-back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 0 16px;
    display: block;
}

.progress-chart-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    animation: progress-panel-in 0.18s ease-out;
}

@keyframes progress-panel-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.progress-chart-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    margin-bottom: 14px;
}

.progress-chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 10px;
}

.progress-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.progress-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.progress-legend-dot.accent { background: var(--accent); }
.progress-legend-dot.muted  { background: var(--text-muted); }

.progress-stats-row {
    display: flex;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.progress-stat {
    flex: 1;
    text-align: center;
}

.progress-stat + .progress-stat {
    border-left: 1px solid var(--border);
}

.progress-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-stat-label {
    font-size: 0.65rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
}

.progress-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    color: var(--text-soft);
    gap: 8px;
}

.progress-empty-icon  { font-size: 2.5rem; opacity: 0.3; }
.progress-empty-text  { font-size: 1rem; font-weight: 600; opacity: 0.6; }
.progress-empty-sub   { font-size: 0.85rem; opacity: 0.4; }

/* ═══ Achievements ═══ */

.ach-hero {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
}

.ach-hero-cell { flex: 1; text-align: center; }

.ach-hero-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.ach-hero-total { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); }

.ach-hero-label {
    font-size: 0.65rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.ach-hero-divider { width: 1px; align-self: stretch; background: var(--border); }

.ach-hero-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 18px;
}

.ach-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 18px;
}

@media (min-width: 560px) {
    .ach-grid { grid-template-columns: 1fr 1fr; }
}

.ach-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.ach-card.locked { opacity: 0.55; }
.ach-card.unlocked { border-color: var(--accent-dim); }

.ach-icon { font-size: 1.5rem; line-height: 1.2; flex-shrink: 0; }
.ach-card.locked .ach-icon { filter: grayscale(1); }

.ach-body { min-width: 0; flex: 1; }
.ach-title { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); }
.ach-desc { font-size: 0.78rem; color: var(--text-soft); margin-top: 2px; line-height: 1.35; }
.ach-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 5px; }
.ach-meta.unlocked { color: var(--accent); }

.ach-progress {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 7px;
}

.ach-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* Entry strip on the Progress tab */
.ach-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 14px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.ach-strip:active { background: var(--bg-elevated); border-color: var(--accent-dim); }
.ach-strip-main { display: flex; gap: 20px; }
.ach-strip-value { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

.ach-strip-label {
    font-size: 0.62rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.ach-strip-chevron { color: var(--text-muted); font-size: 1.1rem; }

/* Unlock cards on the post-session summary */
.ach-unlock-kicker {
    font-size: 0.62rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 6px;
}

.ach-unlock {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 8px;
}

.ach-unlock-icon { font-size: 1.4rem; }
.ach-unlock-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.ach-unlock-desc { font-size: 0.75rem; color: var(--text-soft); margin-top: 1px; }

/* ═══ Supplement Tracking ═══ */

.supplement-empty {
    color: var(--text-soft);
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.supplement-start-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.supplement-start-btn:hover {
    filter: brightness(1.1);
}

.supplement-active-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
}

.supplement-active-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.supplement-active-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.supplement-active-started {
    font-size: 0.78rem;
    color: var(--text-soft);
}

.supplement-active-empty {
    color: var(--text-soft);
    font-size: 0.85rem;
    font-style: italic;
    padding: 6px 0;
}

.supplement-entry-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.supplement-entry-display {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    font-size: 0.9rem;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border);
}

.supplement-entry-display:last-child {
    border-bottom: none;
}

.supplement-entry-display-name {
    color: var(--text-primary);
    font-weight: 500;
}

.supplement-entry-display-dose {
    color: var(--text-soft);
    font-size: 0.85rem;
    text-align: right;
}

.supplement-active-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.supplement-edit-btn,
.supplement-stop-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
}

.supplement-edit-btn {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.supplement-stop-btn {
    background: var(--bg-surface);
    color: var(--danger, #c94a4a);
}

.supplement-edit-btn:hover { background: var(--bg-hover, var(--bg-surface)); }
.supplement-stop-btn:hover { filter: brightness(1.1); }

/* Form */
.supplement-form {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
}

.supplement-form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.supplement-form-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    font-weight: 600;
}

.supplement-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.9rem;
    color: var(--text-primary);
    width: 100%;
    box-sizing: border-box;
}

.supplement-input:focus {
    outline: none;
    border-color: var(--accent);
}

.supplement-entry-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    align-items: center;
}

.supplement-entry-name { flex: 1 1 40%; }
.supplement-entry-dose { flex: 1 1 55%; }

.supplement-entry-remove {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.supplement-entry-remove:hover {
    color: var(--danger, #c94a4a);
}

.supplement-add-entry-btn {
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-top: 8px;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.supplement-add-entry-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.supplement-form-error {
    color: var(--danger, #c94a4a);
    font-size: 0.85rem;
    margin-top: 8px;
}

.supplement-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.supplement-save-btn,
.supplement-cancel-btn {
    flex: 1;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.supplement-save-btn {
    background: var(--accent);
    color: #fff;
}

.supplement-cancel-btn {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* History */
.supplement-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.supplement-history-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.supplement-history-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}

.supplement-history-header:hover {
    background: var(--bg-hover, var(--bg-surface));
}

.supplement-history-caret {
    color: var(--text-soft);
    font-size: 0.8rem;
    width: 12px;
}

.supplement-history-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.supplement-history-dates {
    font-size: 0.78rem;
    color: var(--text-soft);
}

.supplement-history-body {
    padding: 0 14px 12px 14px;
    border-top: 1px solid var(--border);
}

/* ═══ Body Metrics ═══ */

.body-metric-current-strip {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.body-metric-current-cell {
    flex: 1;
    text-align: center;
    padding: 14px 8px;
}

.body-metric-current-cell + .body-metric-current-cell {
    border-left: 1px solid var(--border);
}

.body-metric-current-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.body-metric-current-unit {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-soft);
}

.body-metric-current-label {
    font-size: 0.65rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 3px;
}

/* Log button */
.body-metric-log-btn {
    width: 100%;
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 0.9rem;
    padding: 12px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 12px;
}
.body-metric-log-btn:hover { background: var(--bg-surface); border-color: var(--accent); }

/* Inline form */
.body-metric-form {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.body-metric-form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.body-metric-form-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.body-metric-form-label {
    font-size: 0.75rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.body-metric-form-optional {
    font-size: 0.7rem;
    color: var(--text-soft);
    text-transform: none;
    letter-spacing: 0;
}

.body-metric-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 9px 12px;
    width: 100%;
    outline: none;
    transition: border-color var(--transition);
}
.body-metric-input:focus { border-color: var(--accent); }

/* Remove number input arrows */
.body-metric-input[type=number]::-webkit-inner-spin-button,
.body-metric-input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.body-metric-input[type=number] { -moz-appearance: textfield; }

.body-metric-form-error {
    font-size: 0.8rem;
    color: var(--error);
    margin-bottom: 10px;
}

.body-metric-form-actions {
    display: flex;
    gap: 8px;
}

.body-metric-save-btn {
    flex: 1;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px;
    cursor: pointer;
    transition: opacity var(--transition);
}
.body-metric-save-btn:active { opacity: 0.8; }

.body-metric-cancel-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 10px 18px;
    cursor: pointer;
    transition: border-color var(--transition);
}
.body-metric-cancel-btn:hover { border-color: var(--text-secondary); }

/* Chart panel */
.body-metric-chart-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.body-metric-chart-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.body-metric-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.body-metric-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.body-metric-legend-dot.accent { background: var(--accent); }
.body-metric-legend-dot.muted  { background: var(--text-muted); }

/* History list */
.body-metric-history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.body-metric-history-row {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    gap: 10px;
}

.body-metric-history-date {
    font-size: 0.82rem;
    color: var(--text-soft);
    flex: 1;
}

.body-metric-history-values {
    display: flex;
    gap: 12px;
    align-items: center;
}

.body-metric-history-weight {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.body-metric-history-bf {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.body-metric-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
    transition: color var(--transition);
    flex-shrink: 0;
}
.body-metric-delete-btn:hover { color: var(--error); }

.body-metric-empty {
    font-size: 0.85rem;
    color: var(--text-soft);
    text-align: center;
    padding: 12px 0 16px;
}

/* ═══ Last Workout Card (Home) ═══ */

.last-workout-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
}

.last-workout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.last-workout-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.last-workout-date {
    font-size: 0.72rem;
    color: var(--text-soft);
}

.last-workout-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.last-workout-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.last-workout-lift {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
}

.history-sentinel {
    height: 1px;
}

.history-loading {
    text-align: center;
    color: var(--text-soft);
    font-size: 0.8rem;
    padding: 8px 0;
}

.history-pull-hint {
    text-align: center;
    color: var(--text-soft);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 8px 0 4px;
    opacity: 0.6;
}

/* ═══ Inline Form Header (Exercises tab) ═══ */

.inline-form-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.inline-form-back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.inline-form-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ═══ Supersets ═══ */

/* Template create — border around each linked card in its superset's color */
.template-exercise-row.superset-top {
    border-color: var(--ss-color, var(--accent));
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
}
.template-exercise-row.superset-bottom {
    border-color: var(--ss-color, var(--accent));
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Link button floats centered over the junction between the two cards */
.superset-link-row {
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 2;
    margin: -11px 0;    /* overlap both card borders equally */
}
.superset-link-btn {
    position: relative;
    background: var(--bg-primary);  /* solid so it covers the border line */
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 3px 14px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: color var(--transition), border-color var(--transition);
}
.superset-link-btn.active {
    border-color: var(--ss-color, var(--accent));
    color: var(--ss-color, var(--accent));
    font-weight: 600;
}

/* SupersetCard — workout execution */

/* Divider between the two exercises */
.superset-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    color: var(--ss-color, var(--accent));
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}
.superset-divider::before,
.superset-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, var(--ss-color, var(--accent)) 35%, transparent);
}

/* Per-superset color, assigned by order of appearance in the session.
   Index 0 tracks the theme accent; the rest are fixed hues readable on light and dark. */
.ss-color-0 { --ss-color: var(--accent); }
.ss-color-1 { --ss-color: #A855F7; }
.ss-color-2 { --ss-color: #F59E0B; }
.ss-color-3 { --ss-color: #14B8A6; }
.ss-color-4 { --ss-color: #EC4899; }

/* Collapsed LIST view — superset rows outlined in their superset's color */
.collapsed-exercise-row.superset-row {
    border: 2px solid var(--ss-color, var(--accent));
}

/* The currently selected exercise reads green even when it's a superset row */
.collapsed-exercise-row.superset-row.active {
    border-color: var(--success);
}

/* Rounded outline around each exercise inside a superset card */
.superset-exercise-outline {
    border: 2px solid color-mix(in srgb, var(--ss-color, var(--accent)) 65%, transparent);
    border-radius: var(--radius);
    padding: 10px 10px 12px;
    margin-bottom: 8px;
}

/* ═══ Exercise Reorder Buttons ═══ */

.reorder-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    margin-right: 8px;
}
.reorder-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1;
    padding: 1px 4px;
    cursor: pointer;
    border-radius: 3px;
    transition: color var(--transition), background var(--transition);
    user-select: none;
}
.reorder-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-elevated);
}
.reorder-btn:disabled {
    opacity: 0.2;
    cursor: default;
}

.exercise-name-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══ Onboarding Wizard ═══ */

.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.onboarding-card {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.onboarding-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background var(--transition), transform var(--transition);
}

.onboarding-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

.onboarding-dot.done {
    background: color-mix(in srgb, var(--accent) 50%, transparent);
}

.onboarding-icon {
    font-size: 3rem;
    text-align: center;
    line-height: 1;
}

.onboarding-intro {
    max-height: 65vh;
    overflow-y: auto;
    padding: 4px 8px 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.55;
    scrollbar-width: none;
}

.onboarding-intro::-webkit-scrollbar {
    display: none;
}

.onboarding-pillars {
    padding-left: 18px;
}

.onboarding-intro .onboarding-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.onboarding-intro h3 {
    margin: 20px 0 8px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.onboarding-intro h4 {
    margin: 14px 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

.onboarding-intro p {
    margin: 6px 0;
    color: var(--text-secondary);
    text-align: center;
}

.onboarding-intro ul {
    margin: 4px 0 10px;
    padding-left: 40px;
    color: var(--text-secondary);
}

.onboarding-intro li {
    margin: 2px 0;
}

.onboarding-intro strong {
    color: var(--text-primary);
}

.onboarding-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.onboarding-subtitle {
    font-size: 0.9rem;
    color: var(--text-soft);
    text-align: center;
    line-height: 1.5;
    margin-top: -8px;
}

.onboarding-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.onboarding-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
}

.onboarding-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    box-sizing: border-box;
    transition: border-color var(--transition);
}

.onboarding-input:focus {
    outline: none;
    border-color: var(--accent);
}

.onboarding-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    scrollbar-width: none;
}

.onboarding-choices::-webkit-scrollbar { display: none; }

.onboarding-choice {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.onboarding-choice.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-elevated));
}

.onboarding-choice-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.onboarding-choice.compact .onboarding-choice-title {
    margin-bottom: 2px;
}

.onboarding-choice-sub {
    font-size: 0.8rem;
    color: var(--text-soft);
    line-height: 1.4;
}

.onboarding-error {
    font-size: 0.82rem;
    color: var(--danger, #ff6464);
    text-align: center;
}

.onboarding-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
}

.onboarding-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 0;
    transition: color var(--transition);
}

.onboarding-back:hover { color: var(--text-primary); }

.onboarding-next {
    padding: 13px 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
}

.onboarding-next.finish {
    background: var(--accent);
    color: #fff;
    padding: 13px 36px;
}

.onboarding-next:disabled {
    opacity: 0.35;
    cursor: default;
}

.onboarding-next:not(:disabled):hover {
    background: var(--bg-card);
}

.onboarding-next.finish:not(:disabled):hover {
    background: var(--accent-dim);
}

/* ── AI Chat Audit (admin) ───────────────────────────────────── */
.audit-scan-result {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.audit-counts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.audit-count-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.audit-count-card.audit-count-high {
    border-color: var(--error);
}

.audit-count-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.audit-count-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.audit-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audit-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.audit-row-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.audit-severity {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.audit-severity.audit-sev-high {
    background: var(--error);
    color: #fff;
}

.audit-severity.audit-sev-review {
    background: var(--warning);
    color: #000;
}

.audit-category {
    font-weight: 600;
    color: var(--text-primary);
}

.audit-role,
.audit-user,
.audit-time {
    color: var(--text-muted);
}

.audit-time {
    margin-left: auto;
}

.audit-reason {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
}

.audit-content {
    background: var(--bg-elevated);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

.audit-transcript-btn {
    margin-top: 10px;
    background: none;
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    cursor: pointer;
}

.audit-transcript-btn:hover {
    background: var(--bg-elevated);
}

.audit-transcript {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.audit-transcript-msg {
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
}

.audit-transcript-system {
    opacity: 0.7;
    font-size: 0.8rem;
}

.audit-transcript-user {
    border-left: 3px solid var(--accent);
}

.audit-transcript-assistant {
    border-left: 3px solid var(--success);
}

.audit-transcript-role {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
}

.audit-transcript-flag {
    color: var(--error);
    font-weight: 600;
}

/* Marks a coach message the safety review suppressed: the row shows the model's original
   words, but the user was served a neutral fallback instead. */
.audit-blocked {
    color: var(--error);
    font-weight: 600;
    white-space: nowrap;
}

.audit-transcript-content {
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
}

.profile-setting-link {
    cursor: pointer;
}

.profile-setting-link:hover {
    background: var(--bg-elevated);
}

.profile-setting-chevron {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* ── Coaching disclaimer + onboarding consent (liability) ────── */
.coaching-disclaimer {
    flex-shrink: 0;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-soft);
    font-size: 0.72rem;
    line-height: 1.4;
    text-align: center;
}

.onboarding-consent-points {
    margin: 4px 0 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.onboarding-consent-points li {
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.onboarding-consent-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 4px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.onboarding-consent-check input[type="checkbox"] {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
}

.onboarding-consent-check span {
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-primary);
}

/* WorkoutSummary — "Modify" opt-out from the auto-applied progression */

.modify-target-btn {
    margin-top: 10px;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--transition), color var(--transition);
}

.modify-target-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.modify-target-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* Manual next-session target entry — revealed by "Modify". */
.next-target-edit {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.next-target-edit .set-input-group {
    flex: 1;
    min-width: 0;
}

.results-card .prev-target {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.results-card .target-arrow {
    color: var(--accent);
    margin: 0 6px;
}

/* History chips — per-exercise session outcome (red = Miss, amber = Partial) */

.last-workout-lift {
    border: 1px solid transparent;
}

.last-workout-lift.miss {
    border-color: rgba(220, 53, 69, 0.7);
    color: rgba(220, 53, 69, 0.9);
}

.last-workout-lift.partial {
    border-color: rgba(230, 162, 60, 0.65);
    color: rgba(230, 162, 60, 0.9);
}

/* ═══════════════════════════════════════════════════
   Community — connections, requests, activity feed
   ═══════════════════════════════════════════════════ */

.community-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    margin: 22px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.community-count {
    color: var(--accent);
}

.community-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.community-row {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.community-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}

.community-row-main {
    flex: 1;
    min-width: 0;
}

.community-row-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.community-row-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.community-row-time {
    font-size: 0.75rem;
    color: var(--text-soft);
    flex-shrink: 0;
    white-space: nowrap;
}

.community-row.unread {
    border-color: var(--accent-dim);
}

.community-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.community-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.community-btn:hover:not(:disabled) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.community-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.community-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.community-btn.primary:hover:not(:disabled) {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
    color: #fff;
}

.community-btn.danger {
    color: var(--error);
    border-color: color-mix(in srgb, var(--error) 45%, transparent);
}

.community-btn.danger:hover:not(:disabled) {
    border-color: var(--error);
    color: var(--error);
}

.community-empty {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    color: var(--text-soft);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Invite codes */

.community-code-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.community-code {
    flex: 1;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--accent);
    word-break: break-all;
}

.community-code-expiry {
    font-size: 0.75rem;
    color: var(--text-soft);
    margin-top: 2px;
    letter-spacing: normal;
    font-family: inherit;
    font-weight: 400;
}

.community-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color var(--transition);
}

.community-input:focus {
    outline: none;
    border-color: var(--accent);
}

.community-input.code-entry {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.community-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.community-input-row .community-input {
    flex: 1;
}

.community-hint {
    font-size: 0.78rem;
    color: var(--text-soft);
    line-height: 1.45;
    margin: 6px 0 10px;
}

.community-error {
    font-size: 0.82rem;
    color: var(--error);
    margin-top: 8px;
    line-height: 1.4;
}

.community-notice {
    font-size: 0.82rem;
    color: var(--success);
    margin-top: 8px;
    line-height: 1.4;
}

/* Per-connection manage panel — revealed inline rather than in a menu */

.community-manage {
    border-top: 1px solid var(--border);
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.community-manage-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.community-row-stack {
    flex-direction: column;
    align-items: stretch;
}

.community-row-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.community-report-input {
    width: 100%;
    min-height: 70px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.community-report-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Consent gate — same visual language as the onboarding consent step */

/* Program day rows — right-aligned cluster so NEXT and Share can coexist */

.program-day-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.program-day-share-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.program-day-share-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Shared workouts — preview of a workout a connection sent, before it is saved */

.shared-exercise-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shared-exercise-row {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.shared-exercise-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shared-exercise-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Marks an exercise the recipient does not have yet — saving will create it as a custom
   exercise, and that should never be a surprise. */
.shared-exercise-new {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    border-radius: 4px;
    padding: 2px 5px;
    flex-shrink: 0;
}

.shared-exercise-meta {
    font-size: 0.76rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.shared-exercise-note {
    font-size: 0.76rem;
    color: var(--text-soft);
    font-style: italic;
    margin-top: 4px;
    line-height: 1.4;
}

/* Selection tick in the share sheet's connection list */

.share-check {
    width: 22px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: transparent;
    transition: all var(--transition);
}

.share-check.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.community-consent-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 8px;
}

.community-consent-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* Unread badge on the Community tab */

.tab-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 6px;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

/* ═══ Loading spinner ═══ */

.loading-spinner-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.loading-spinner-wrap.small { padding: 8px 0; }

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border, rgba(127, 127, 127, 0.25));
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: loading-spin 0.8s linear infinite;
}

.loading-spinner-wrap.small .loading-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

@keyframes loading-spin {
    to { transform: rotate(360deg); }
}


/* ═══════════════════════════════════════════════════
   Program Runs — Home run card + run length picker
   ═══════════════════════════════════════════════════ */

.run-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.run-card-title {
    font-weight: 700;
    color: var(--text-primary);
}

.run-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.run-meter {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
}

.run-meter-fill {
    height: 100%;
    background: var(--accent);
}

.run-link-btn {
    background: none;
    border: none;
    padding: 4px 0;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.run-review-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.run-review-actions .template-edit-btn {
    padding: 12px;
}

.run-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-stepper .template-edit-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    flex: none;
}

.run-stepper-value {
    flex: 1;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

/* Run goals — list on the run card and the goal editor. Deliberately plain: every goal kind,
   bodyweight above all, uses the card's neutral text colours (no success greens or celebration). */

.run-goal-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.run-goal-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.run-goals-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.run-goal-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.run-goal-heading {
    font-weight: 600;
    color: var(--text-primary);
}

.run-goal-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.run-goal-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-goal-inputs .template-form-input {
    flex: 1;
    min-width: 0;
}

.run-goal-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.run-goal-disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ═══════════════════════════════════════════════════
   Program Runs — Progress → Runs tab + run comparison
   Neutral on purpose: no run is coloured as better or worse,
   because side-by-side results can't support a verdict.
   ═══════════════════════════════════════════════════ */

.run-view-toggle {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.run-view-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.run-view-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.run-list-card {
    background: var(--bg-elevated);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.run-list-card-selectable {
    cursor: pointer;
}

.run-list-card-picked {
    border-color: var(--accent);
}

.run-list-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.run-list-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.run-status-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text-soft);
}

.run-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: 4px;
    background: var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
}

.run-compare-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.run-caveats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.run-caveat {
    padding: 8px 10px;
    border-left: 3px solid var(--text-muted);
    border-radius: 4px;
    background: var(--bg-elevated);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.run-explainer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.run-compare-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.run-compare-head,
.run-compare-cells {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.run-compare-head {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.run-compare-row {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.run-compare-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.run-compare-col {
    min-width: 0;
    overflow-wrap: anywhere;
}

.run-compare-value {
    font-weight: 600;
    color: var(--text-primary);
}

.run-compare-rate {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.run-compare-muted {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.run-only {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 10px;
}

.run-only-label {
    font-weight: 600;
    color: var(--text-primary);
}

.run-footnote {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 18px 0 8px;
}

/* ── Admin error log (ErrorLog.razor) — reuses the audit-* row styles ── */
.errorlog-search {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.errorlog-input {
    flex: 1 1 220px;
    width: auto;
}

.errorlog-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.errorlog-clear {
    margin-top: 0;
}

.errorlog-row-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

/* Spans inside a <button>, so restore the block/flex display the audit-* classes assume. */
.errorlog-row-btn .audit-row-head {
    display: flex;
}

.errorlog-row-btn .audit-content {
    display: block;
}

.errorlog-row-btn:hover .audit-category,
.errorlog-row-open .audit-category {
    color: var(--accent);
}

.errorlog-preview {
    font-size: 0.85rem;
}

.errorlog-detail {
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.errorlog-fields {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 0 0 12px;
    font-size: 0.85rem;
}

.errorlog-fields dt {
    color: var(--text-muted);
}

.errorlog-fields dd {
    margin: 0;
    color: var(--text-primary);
    word-break: break-all;
}

.errorlog-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 8px 0 4px;
}

.errorlog-pre {
    background: var(--bg-elevated);
    border-radius: 8px;
    padding: 12px;
    margin: 0;
    color: var(--text-primary);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 480px;
    overflow: auto;
}

.errorlog-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.errorlog-pager .audit-time {
    margin-left: 0;
}

.errorlog-pager .audit-transcript-btn {
    margin-top: 0;
}
