/* ═══════════════════════════════════════════════════════════════════════
   Steel AI
   Cool-neutral dark theme (less yellow) · Card layout · Responsive · Animated
   Revert: restore public/css/tracker.css from tracker.css.backup
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ──────────────────────────────────────────────── */
:root {
    --bg:              #0a0b0f;
    --bg-card:         #13141a;
    --bg-card-hover:   #191a22;
    --bg-elevated:     #1f2028;
    --bg-input:        #0c0d11;
    --bg-badge:        rgba(200, 165, 116, 0.08);
    --bg-header:       rgba(10, 11, 15, 0.92);

    /* Dustier gold (less pure yellow) than #e8a234 */
    --accent:          #c4a574;
    --accent-dim:      #9d8560;
    --accent-hover:    #d6bc8e;
    --accent-glow:     rgba(200, 165, 116, 0.16);
    --accent-muted:    rgba(200, 165, 116, 0.30);

    --text:            #e6e9ef;
    --text-sub:        #9ca4b2;
    --text-muted:      #6b7285;
    /* Meta on cards / dark panels — tuned for ≥4.5:1 vs --bg-card where used at small sizes */
    --text-faint:      #6d7688;

    /* Supporting UI copy: labels, meta, helper lines, secondary buttons. Tune these app-wide. */
    --text-ui:         #aab4c4;
    --text-ui-muted:   #98a4b8;
    --text-ui-strong:  #d0d6e0;

    /* Placeholders sit on --bg-input (#0c0d11); keep lighter than body secondary text */
    --text-placeholder: #9caab8;

    --border:          #262a32;
    --border-card:     #2c303a;
    --border-focus:    #c4a574;

    /* Semantic: coach, danger, success, warning, info — rgb() + *-rgb for rgba(var(--*-rgb), a) */
    --coach:           rgb(124, 58, 237);
    --coach-deep:      rgb(109, 40, 217);
    --coach-mid:       rgb(139, 92, 246);
    --coach-soft:      rgb(167, 139, 250);
    --coach-faint:     rgb(196, 181, 253);
    --coach-rgb:       124, 58, 237;

    --danger:          rgb(239, 68, 68);
    --danger-soft:     rgb(248, 113, 113);
    --danger-ink:      rgb(224, 90, 90);
    --danger-rgb:      239, 68, 68;

    --success:         rgb(22, 163, 74);
    --success-bright:  rgb(34, 197, 94);
    --success-soft:    rgb(74, 222, 128);
    --success-rgb:     34, 197, 94;

    --warning:         rgb(245, 158, 11);
    --warning-soft:    rgb(251, 191, 36);
    --warning-rgb:     245, 158, 11;

    --info:            rgb(147, 197, 253);
    --info-rgb:        59, 130, 246;

    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       16px;
    --radius-xl:       22px;

    --shadow-card:     0 2px 12px rgba(0, 0, 0, 0.45);
    --shadow-focus:    0 0 0 3px var(--accent-glow);

    --font:            system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition:      0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1.5rem 0.75rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Brand mark — srcset-friendly sizes; display size via CSS */
.brand-logo {
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Header Action Buttons ──────────────────────────────────────────── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

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

@media (min-width: 769px) {
    .header-inner {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 1rem;
    }

    /* Balance the centered toolbar against the right-column logout */
    .header-inner::before {
        content: "";
        grid-column: 1;
    }

    .header-actions {
        display: contents;
    }

    .header-actions-primary {
        grid-column: 2;
        justify-self: center;
    }

    .header-actions > .btn-logout {
        grid-column: 3;
        justify-self: end;
    }
}

.data-menu {
    position: relative;
}

.data-menu-toggle {
    position: relative;
    z-index: 2;
}

.data-menu-panel {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.3rem;
    min-width: 210px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 0.3rem 0;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
}

.data-menu-panel--open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.data-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.data-menu-item i {
    font-size: 0.8rem;
    color: var(--accent);
}

.data-menu-item:hover,
.data-menu-item:focus-visible {
    outline: none;
    background: var(--bg-elevated);
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), transform var(--transition),
                box-shadow var(--transition);
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn:visited,
.btn:focus-visible,
.btn:active {
    text-decoration: none;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--accent);
    color: #0c0d11;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 0 18px var(--accent-muted);
}

.btn-danger {
    background: rgba(var(--danger-rgb), 0.22);
    color: var(--danger-soft);
    border-color: rgba(var(--danger-rgb), 0.45);
}

.btn-danger:hover {
    background: rgba(var(--danger-rgb), 0.32);
    border-color: rgba(var(--danger-rgb), 0.55);
    color: #f5d4d4;
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-danger:disabled:hover {
    background: rgba(var(--danger-rgb), 0.22);
    border-color: rgba(var(--danger-rgb), 0.45);
    color: var(--danger-soft);
    box-shadow: none;
}

.btn-success {
    background: var(--success-bright);
    color: #06140b;
    border-color: var(--success-soft);
    font-weight: 600;
}

.btn-success:hover {
    background: rgb(52, 211, 110);
    border-color: rgb(134, 239, 172);
    box-shadow: 0 0 18px rgba(var(--success-rgb), 0.35);
    color: #041209;
}

.btn-success:focus-visible {
    outline: 2px solid var(--success-soft);
    outline-offset: 2px;
}

.btn-success:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: var(--bg-elevated);
    color: var(--text-sub);
    border-color: var(--border-card);
}

.btn-ghost:hover {
    background: #252830;
    color: var(--text);
    border-color: var(--accent-dim);
}

/* Header toolbar: soft tinted ghosts (Admin / logout stay plain .btn-ghost) */
.btn.btn-ghost.btn-header-history {
    color: #8ec8eb;
    border-color: rgba(110, 184, 228, 0.36);
    background: rgba(110, 184, 228, 0.07);
}

.btn.btn-ghost.btn-header-history:hover {
    color: #b8dff7;
    background: rgba(110, 184, 228, 0.12);
    border-color: rgba(150, 205, 238, 0.48);
}

.btn.btn-ghost.btn-header-profile {
    color: #8fd4b8;
    border-color: rgba(120, 200, 165, 0.36);
    background: rgba(120, 200, 165, 0.07);
}

.btn.btn-ghost.btn-header-profile:hover {
    color: #b5ead1;
    background: rgba(120, 200, 165, 0.12);
    border-color: rgba(160, 220, 185, 0.48);
}

.btn.btn-ghost.btn-header-coach {
    color: #c4b5e8;
    border-color: rgba(156, 130, 220, 0.36);
    background: rgba(var(--coach-rgb), 0.07);
}

.btn.btn-ghost.btn-header-coach:hover {
    color: #ddd4f5;
    background: rgba(var(--coach-rgb), 0.12);
    border-color: rgba(176, 150, 235, 0.48);
}

.btn.btn-ghost.btn-header-data {
    color: #d4c8a8;
    border-color: rgba(200, 175, 130, 0.36);
    background: rgba(200, 165, 116, 0.07);
}

.btn.btn-ghost.btn-header-data:hover {
    color: #e8ddc8;
    background: rgba(200, 165, 116, 0.12);
    border-color: rgba(215, 188, 145, 0.48);
}

.btn i {
    font-size: 0.85rem;
}

/* Logout / user identity button */
.btn-logout {
    text-decoration: none;
    border-left: 1px solid var(--border-card);
    margin-left: 0.25rem;
    padding-left: 0.9rem;
}

.btn-logout .btn-label {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Tab Navigation ─────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    overflow-x: auto;
    padding: 0 1.5rem 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 0.15rem;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    padding: 0.7rem 1.25rem;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-ui);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tab-btn:hover {
    color: var(--text-sub);
}

.tab-btn.tab-active {
    background: transparent;
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ── Main Content ───────────────────────────────────────────────────── */
.main-content {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 1.5rem;
    padding-bottom: max(3rem, calc(3rem + env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
}

/* ── Initial Loading State ───────────────────────────────────────────── */
.app-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}

.app-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-card);
    color: var(--text-ui);
}

.app-loading .brand-logo--loading {
    width: 48px;
    height: 48px;
    opacity: 0.9;
}

.app-loading-spinner {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 2px solid rgba(200, 165, 116, 0.25);
    border-top-color: var(--accent);
    animation: appLoadingSpin 0.85s linear infinite;
}

.app-loading-text {
    font-size: 0.85rem;
}

@keyframes appLoadingSpin {
    to { transform: rotate(360deg); }
}

/* ── Tab Sections ───────────────────────────────────────────────────── */
.tab-content {
    display: none;
}

.tab-content.tab-active {
    display: block;
    animation: tabEnter var(--transition-slow) cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tabEnter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Overview ───────────────────────────────────────────────────────── */
.overview-hero {
    text-align: center;
    padding: 3rem 2rem 2.5rem;
    background: linear-gradient(160deg, #171922 0%, #11141c 100%);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}

.overview-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 40% at 50% -10%,
                rgba(140, 155, 185, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.overview-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.overview-icon .brand-logo--overview {
    width: 72px;
    height: auto;
    max-width: 100%;
}

.overview-heading {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 0.85rem;
    line-height: 1.3;
}

.overview-desc {
    color: var(--text-ui-strong);
    font-size: 0.95rem;
    max-width: 560px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

/* Row 1: first two stats (e.g. Cycle + Next Deload); row 2+: full width (Goal, extras) */
.overview-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.overview-stats .stat-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.overview-stats .stat-card:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.overview-stats .stat-card:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 2;
}

.overview-stats .stat-card:nth-child(n + 4) {
    grid-column: 1 / -1;
}

.stat-card:only-child {
    grid-column: 1 / -1;
}

.stat-card {
    min-width: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color var(--transition), background var(--transition);
}

.stat-card:hover {
    border-color: var(--accent-dim);
    background: #252830;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-ui);
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

/* Default: 2 columns (avoids 3+1 when four pills). Narrow: 1 col. Wide + exact counts: one row. */
.overview-sessions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.overview-sessions[data-pill-count="1"] {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .overview-sessions[data-pill-count="3"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .overview-sessions[data-pill-count="4"] {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.session-pill[data-tab] {
    cursor: pointer;
}

.session-pill[data-tab]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-glow), 0 0 0 4px rgba(200, 165, 116, 0.2);
}

.session-pill {
    min-width: 0;
    background: rgba(200, 165, 116, 0.06);
    border: 1px solid rgba(200, 165, 116, 0.15);
    border-radius: var(--radius-md);
    padding: 0.9rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: background var(--transition), border-color var(--transition);
}

.session-pill:hover {
    background: rgba(200, 165, 116, 0.1);
    border-color: rgba(200, 165, 116, 0.3);
}

.pill-day {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.pill-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.pill-tag {
    font-size: 0.68rem;
    color: var(--text-ui);
    font-style: italic;
}

/* ── Session Header ─────────────────────────────────────────────────── */
.session-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.session-header-top {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

/* Session tab is the session id; this line is the substantive title (day · name · emphasis) */
.session-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.session-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-ui-strong);
    background: var(--bg-elevated);
    border: 1px solid rgba(200, 165, 116, 0.28);
    border-radius: 999px;
    padding: 0.32rem 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Exercise List & Cards ──────────────────────────────────────────── */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    counter-reset: exercise-counter;
}

.exercise-card {
    counter-increment: exercise-counter;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    border-left: 3px solid var(--border-card);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), background var(--transition),
                box-shadow var(--transition), transform var(--transition);
    animation: cardEnter 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
    will-change: transform, opacity;
}

.tab-content.tab-active .exercise-card:nth-child(1) { animation-delay: 30ms;  }
.tab-content.tab-active .exercise-card:nth-child(2) { animation-delay: 80ms;  }
.tab-content.tab-active .exercise-card:nth-child(3) { animation-delay: 130ms; }
.tab-content.tab-active .exercise-card:nth-child(4) { animation-delay: 180ms; }
.tab-content.tab-active .exercise-card:nth-child(5) { animation-delay: 230ms; }
.tab-content.tab-active .exercise-card:nth-child(6) { animation-delay: 280ms; }
.tab-content.tab-active .exercise-card:nth-child(7) { animation-delay: 330ms; }

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.exercise-card:hover {
    border-left-color: var(--accent-dim);
    background: var(--bg-card-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-card);
    transform: translateY(-1px);
}

/* ── Card Top (name row + full-width schema/rest row) ───────────────── */
.card-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    margin-bottom: 1.1rem;
}

.card-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-width: 0;
}

.card-top-row::before {
    content: counter(exercise-counter, decimal-leading-zero);
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-ui-muted);
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
    min-width: 1.6rem;
    font-variant-numeric: tabular-nums;
}

.card-name-group {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.exercise-name-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    width: 100%;
}

.exercise-name {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.exercise-info-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.3rem;
    box-sizing: border-box;
    min-width: 2.25rem;
    min-height: 2.25rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.exercise-info-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Emphasis on the glyph only; currentColor in SVG picks this up */
.exercise-info-btn__svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--accent);
    transition: filter var(--transition), color var(--transition);
}

/* Glow only on the icon, only where hover is meaningful (e.g. mouse) */
@media (hover: hover) and (pointer: fine) {
    .exercise-info-btn:hover .exercise-info-btn__svg {
        color: var(--accent);
        filter:
            brightness(1.15)
            drop-shadow(0 0 3px var(--accent-muted))
            drop-shadow(0 0 10px var(--accent-glow))
            drop-shadow(0 0 18px rgba(200, 165, 116, 0.28));
    }
}

/* Prescription (sets/reps): same “badge” language as load + rest — violet accent */
.exercise-schema-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    margin-top: 0.35rem;
    background: rgba(168, 140, 210, 0.14);
    border: 1px solid rgba(168, 140, 210, 0.42);
    color: #d4c4ec;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    line-height: 1.25;
    transition: background var(--transition), border-color var(--transition);
}

.exercise-card:hover .exercise-schema-badge {
    background: rgba(168, 140, 210, 0.22);
    border-color: rgba(190, 165, 230, 0.55);
}

.preview-exercises .exercise-schema-badge {
    margin-top: 0;
}

/* Full width of .card-top so rest aligns with prescribed-badge (same right edge) */
.card-schema-rest-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    width: 100%;
    flex-wrap: wrap;
    box-sizing: border-box;
    padding-left: 2rem;
    min-width: 0;
}

.card-schema-rest-row .exercise-schema-badge {
    margin-top: 0;
    margin-left: 0;
    flex-shrink: 0;
}

.progression-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    line-height: 1.25;
    background: rgba(120, 180, 140, 0.14);
    border: 1px solid rgba(120, 180, 140, 0.42);
    color: #b0dbbe;
    flex-shrink: 0;
}

.preview-exercises .progression-badge {
    font-size: 0.62rem;
    padding: 0.15rem 0.4rem;
}

.card-schema-rest-row .rest-inline {
    flex: 0 0 auto;
    width: auto;
    margin-left: auto;
    margin-bottom: 0;
    justify-content: flex-end;
}

.card-schema-rest-row .rest-inline-actions {
    margin-left: 0;
}

/* Rest: label + pill (in .card-schema-rest-row next to schema badge, or legacy fallback) */
.rest-inline {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    margin-bottom: 0.75rem;
    width: 100%;
}

.rest-inline .field-label--rest {
    flex-shrink: 0;
    margin: 0;
}

.rest-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    background: rgba(110, 168, 190, 0.12);
    border: 1px solid rgba(110, 168, 190, 0.38);
    color: #8ec4d4;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    line-height: 1.2;
    transition: background var(--transition), border-color var(--transition);
}

.rest-badge .fa-clock {
    font-size: 0.7rem;
    opacity: 0.9;
    flex-shrink: 0;
}

.rest-badge .rest-value {
    font-style: normal;
}

.exercise-card:hover .rest-badge {
    background: rgba(110, 168, 190, 0.2);
    border-color: rgba(130, 190, 210, 0.55);
}

/* Rest timer (interactive): pill as button + reset + live region row */
.rest-inline-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    margin-left: auto;
    justify-content: flex-end;
}

button.rest-badge.rest-timer-main {
    margin: 0;
    margin-left: 0;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    color: inherit;
}

button.rest-badge.rest-timer-main:focus-visible {
    outline: 2px solid var(--accent, #c9a66b);
    outline-offset: 2px;
}

.rest-timer--running {
    box-shadow: 0 0 0 1px rgba(130, 210, 230, 0.45);
}

.rest-timer--paused {
    opacity: 0.88;
    border-style: dashed;
}

.rest-inline--timer-active .rest-timer-main.rest-timer--ringing,
.exercise-card--rest-ringing .rest-timer-main.rest-timer--ringing {
    animation: rest-timer-glow 1.4s ease-in-out infinite alternate;
}

@keyframes rest-timer-glow {
    from {
        box-shadow: 0 0 6px rgba(130, 210, 230, 0.35);
        border-color: rgba(130, 190, 210, 0.55);
    }
    to {
        box-shadow: 0 0 16px rgba(160, 230, 250, 0.55);
        border-color: rgba(180, 230, 250, 0.85);
    }
}

@media (prefers-reduced-motion: reduce) {
    .rest-inline--timer-active .rest-timer-main.rest-timer--ringing,
    .exercise-card--rest-ringing .rest-timer-main.rest-timer--ringing {
        animation: none;
        box-shadow: 0 0 0 2px rgba(160, 230, 250, 0.5);
        border-color: rgba(180, 230, 250, 0.75);
    }
}

.rest-timer--readonly {
    cursor: default;
}

.prescribed-badge {
    flex-shrink: 0;
    background: var(--bg-badge);
    border: 1px solid var(--accent-muted);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    align-self: flex-start;
    transition: background var(--transition), border-color var(--transition);
}

.exercise-card:hover .prescribed-badge {
    background: rgba(200, 165, 116, 0.16);
    border-color: var(--accent);
}

/* ── Input Row ──────────────────────────────────────────────────────── */
.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: end;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: text;
}

.field-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-ui);
    user-select: none;
}

input[type="text"],
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
    transition: border-color var(--transition), box-shadow var(--transition),
                background var(--transition);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-placeholder);
    font-size: 0.82rem;
}

input[type="text"]:focus,
textarea:focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
    background: #12141c;
}

input[type="text"]:not(:placeholder-shown),
textarea:not(:placeholder-shown) {
    border-color: rgba(200, 165, 116, 0.25);
    color: var(--text);
}

.field-rpe input {
    text-align: center;
    font-weight: 600;
}

/* ── Per-Set Logging Table ─────────────────────────────────────────── */
.sets-table {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 1rem;
}

.sets-header,
.sets-body {
    width: 100%;
    min-width: 0;
}

/* Line | Set # | Reps | Weight (1fr) | RPE (fixed equal) | remove */
.sets-header {
    display: grid;
    grid-template-columns: 2.25rem 3.35rem 4.65rem 1fr 4.65rem 1.85rem;
    gap: 0.4rem;
    padding: 0 0.15rem 0.35rem;
}

.sets-header span {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-ui-muted);
    user-select: none;
}

.sets-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.set-row {
    display: grid;
    grid-template-columns: 2.25rem 3.35rem 4.65rem 1fr 4.65rem 1.85rem;
    gap: 0.4rem;
    align-items: center;
    animation: setRowEnter 0.2s ease both;
}

@keyframes setRowEnter {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.set-number {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-ui-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.set-row input[type="text"] {
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
}

.set-row select.set-reps-select,
.set-row select.set-rpe-select,
.set-row select.set-performed-count-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.35rem 0.45rem;
    font-size: 0.85rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
        linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 0.65rem) 55%, calc(100% - 0.45rem) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.set-row select.set-performed-count-select {
    text-align: center;
    font-weight: 600;
    padding-left: 0.35rem;
    padding-right: 1.05rem;
}

.sets-header-count-label {
    text-align: center;
}

.set-row select.set-rpe-select {
    text-align: center;
    font-weight: 600;
    padding-right: 1.15rem;
}

.set-row select.set-reps-select {
    padding-right: 1.15rem;
}

.set-row select.set-reps-select:focus,
.set-row select.set-rpe-select:focus,
.set-row select.set-performed-count-select:focus {
    outline: none;
    border-color: rgba(200, 165, 116, 0.45);
    box-shadow: 0 0 0 2px rgba(200, 165, 116, 0.12);
}

.set-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 0.7rem;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.set-remove-btn:hover {
    color: #e54;
    background: rgba(238, 85, 68, 0.1);
}

/* First tap arms; second tap within JS window removes (see tracker.js) */
.set-remove-btn--armed {
    color: #e54;
    background: rgba(238, 85, 68, 0.16);
    box-shadow: 0 0 0 1px rgba(238, 85, 68, 0.42);
}

/* Primary “Add line”: ~½ height, ~⅔ width; centered in .sets-table (flex cross-axis) */
.btn.btn-primary.btn-add-set {
    display: flex;
    align-self: center;
    box-sizing: border-box;
    width: calc(100% * 2 / 3);
    max-width: 100%;
    margin-top: 0.55rem;
    margin-left: 0;
    margin-right: 0;
    min-height: 22px;
    padding: 0.22rem 0.75rem;
    justify-content: center;
    letter-spacing: 0.02em;
    font-size: 0.825rem;
    line-height: 1.25;
}

.btn.btn-primary.btn-add-set:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.btn.btn-primary.btn-add-set i {
    font-size: 0.72rem;
    opacity: 0.95;
}

/* ── Coach Notes (details) ──────────────────────────────────────────── */
.coach-notes {
    margin-bottom: 1rem;
}

.coach-notes summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-ui);
    cursor: pointer;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    list-style: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: color var(--transition), background var(--transition);
}

.coach-notes summary::-webkit-details-marker {
    display: none;
}

.coach-notes summary::before {
    content: '\f0da';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.65rem;
    color: var(--text-ui-muted);
    transition: transform var(--transition), color var(--transition);
    display: inline-block;
}

.coach-notes[open] summary::before {
    transform: rotate(90deg);
    color: var(--accent-dim);
}

.coach-notes summary:hover {
    color: var(--text-ui-strong);
    background: var(--bg-elevated);
}

.coach-notes[open] summary {
    color: var(--text-ui-strong);
    margin-bottom: 0.5rem;
}

.coach-notes p {
    font-size: 0.85rem;
    color: var(--text-ui-strong);
    line-height: 1.65;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-left: 2px solid var(--accent-dim);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    animation: noteReveal 0.22s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes noteReveal {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Your Notes ─────────────────────────────────────────────────────── */
.notes-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: text;
}

.notes-group textarea {
    resize: vertical;
    min-height: 52px;
    max-height: 160px;
    line-height: 1.55;
    border-radius: var(--radius-sm);
}

/* ── Save Toast ─────────────────────────────────────────────────────── */
.save-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--bg-elevated);
    border: 1px solid rgba(200, 165, 116, 0.35);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    z-index: 200;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.save-toast.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.save-toast.save-toast--saving.toast-visible {
    border-color: rgba(200, 165, 116, 0.55);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.site-footer {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    color: var(--text-faint);
    font-size: 0.73rem;
    border-top: 1px solid var(--border);
    box-sizing: border-box;
}

.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.site-footer-copy {
    margin: 0;
    text-align: left;
    line-height: 1.4;
    min-width: 0;
    color: var(--text-ui-muted);
}

.brand-logo--footer {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .brand-logo--footer {
        width: 34px;
        height: 34px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        justify-content: flex-end;
        padding: 0.85rem 1rem 0.65rem;
        gap: 0.65rem;
    }

    .header-actions {
        width: 100%;
        gap: 0.4rem;
    }

    .header-actions-primary {
        display: contents;
    }

    .data-menu {
        flex: 1;
    }

    .data-menu-toggle {
        width: 100%;
        justify-content: center;
    }

    .btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.6rem;
        font-size: 0.78rem;
    }

    .btn-label {
        display: none;
    }

    .tab-nav {
        padding: 0 1rem 0.45rem;
    }

    .tab-btn {
        padding: 0.65rem 1rem;
        font-size: 0.82rem;
    }

    .main-content {
        padding: 0.3rem 1rem;
        padding-bottom: max(2.5rem, calc(2.5rem + env(safe-area-inset-bottom, 0px)));
    }

    /* Overview */
    .overview-hero {
        padding: 2rem 1.25rem 1.75rem;
    }

    .overview-heading {
        font-size: 1.2rem;
    }

    .overview-desc {
        font-size: 0.875rem;
    }

    .overview-icon .brand-logo--overview {
        width: 64px;
    }

    .overview-stats {
        gap: 0.65rem;
    }

    .overview-sessions {
        gap: 0.65rem;
    }

    /* Session */
    .session-title {
        font-size: 1.2rem;
    }

    .session-count {
        font-size: 0.76rem;
        padding: 0.28rem 0.65rem;
    }

    /* Cards */
    .exercise-card {
        padding: 1.1rem 1.1rem 1rem;
        border-radius: var(--radius-md);
    }

    .exercise-card:hover {
        transform: none;
    }

    .exercise-name {
        font-size: 0.95rem;
    }

    .card-top {
        margin-bottom: 0.9rem;
    }

    .card-top-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .card-top-row::before {
        display: none;
    }

    .prescribed-badge {
        margin-left: auto;
    }

    /* Input row — tighten gap on mobile */
    .input-row {
        gap: 0.6rem;
    }

    .sets-header,
    .set-row {
        grid-template-columns: 1.75rem 3rem 4.1rem 1fr 4.1rem 1.5rem;
        gap: 0.3rem;
    }

    .set-row input[type="text"] {
        padding: 0.35rem 0.4rem;
        font-size: 0.82rem;
    }

    .set-row select.set-reps-select,
    .set-row select.set-rpe-select,
    .set-row select.set-performed-count-select {
        padding: 0.3rem 1rem 0.3rem 0.35rem;
        font-size: 0.82rem;
    }

    .set-row select.set-performed-count-select {
        padding-right: 0.95rem;
    }

    .save-toast {
        bottom: 1rem;
        right: 1rem;
        font-size: 0.75rem;
        padding: 0.5rem 0.9rem;
    }
}

@media (max-width: 400px) {
    .input-row {
        grid-template-columns: 1fr;
    }

    .overview-sessions {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   DESKTOP — Wider cards
   ═══════════════════════════════════════════════════════════════════════ */

@media (min-width: 900px) {
    .exercise-card {
        padding: 1.4rem 1.75rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   AI COACH — Button, Tab & Chat
   ═══════════════════════════════════════════════════════════════════════ */

/* Accent button variant (distinct from primary gold) */
.btn-accent {
    background: linear-gradient(135deg, var(--coach), var(--coach-deep));
    color: var(--text);
    border-color: var(--coach);
}

.btn-accent:hover {
    background: linear-gradient(135deg, var(--coach-mid), var(--coach));
    border-color: var(--coach-mid);
    box-shadow: 0 0 18px rgba(var(--coach-rgb), 0.35);
}

/* ── Coach Container ───────────────────────────────────────────────── */
.coach-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* Top row: actions (2/3) + quota (1/3) */
.coach-top-row {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}

.coach-top-row .coach-actions {
    flex: 2;
}

.coach-top-row .coach-quota {
    flex: 1;
    margin-bottom: 0;
}

/* ── Quick Actions ─────────────────────────────────────────────────── */
.coach-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.6rem;
}

.coach-quick {
    justify-content: center;
    text-align: center;
    padding: 0.65rem 0.75rem;
    font-size: 0.78rem;
    border-color: rgba(var(--coach-rgb), 0.25);
    color: var(--text-ui);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.coach-quick:hover {
    border-color: rgba(var(--coach-rgb), 0.5);
    color: var(--coach-faint);
    background: rgba(var(--coach-rgb), 0.08);
}

.coach-quick i {
    color: var(--coach-soft);
    margin-right: 0.35rem;
}

/* Primary coach CTA — same gold system as .btn-primary, stronger presence than ghost + .coach-quick */
.btn.btn-primary.coach-quick--generate {
    justify-content: center;
    text-align: center;
    padding: 0.72rem 1.1rem;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: none;
    border-color: var(--accent-dim);
    background: var(--accent);
    color: var(--bg-input);
    box-shadow:
        0 0 0 1px var(--accent-muted) inset,
        0 2px 0 rgba(255, 255, 255, 0.12) inset,
        0 4px 18px rgba(0, 0, 0, 0.45);
}

.btn.btn-primary.coach-quick--generate:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: var(--bg-input);
    box-shadow:
        0 0 0 1px var(--accent-muted) inset,
        0 2px 0 rgba(255, 255, 255, 0.14) inset,
        0 0 26px var(--accent-muted),
        0 4px 20px rgba(0, 0, 0, 0.4);
}

.btn.btn-primary.coach-quick--generate:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 18px rgba(0, 0, 0, 0.45);
}

.btn.btn-primary.coach-quick--generate:active {
    transform: scale(0.98);
}

.btn.btn-primary.coach-quick--generate:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: grayscale(0.12);
}

.btn.btn-primary.coach-quick--generate i {
    color: var(--bg-input);
    opacity: 0.92;
    margin-right: 0.4rem;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.2));
}

.btn.btn-primary.coach-quick--generate:hover i {
    opacity: 1;
}

/* ── Chat Messages ─────────────────────────────────────────────────── */
.chat-messages {
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    scrollbar-width: thin;
    scrollbar-color: var(--border-card) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-card);
    border-radius: 3px;
}

/* Welcome state */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    flex: 1;
}

.chat-welcome-icon {
    font-size: 2.5rem;
    color: var(--coach);
    margin-bottom: 1.25rem;
    opacity: 0.6;
}

.chat-welcome-text {
    color: var(--text-ui);
    font-size: 0.9rem;
    max-width: 360px;
    line-height: 1.6;
}

/* ── Chat Bubbles ──────────────────────────────────────────────────── */
.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.65;
    word-wrap: break-word;
    animation: bubbleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-bubble--user {
    align-self: flex-end;
    background: rgba(var(--coach-rgb), 0.15);
    border: 1px solid rgba(var(--coach-rgb), 0.3);
    color: var(--text);
}

.chat-bubble--ai {
    align-self: flex-start;
    background: var(--bg-elevated);
    border: 1px solid var(--border-card);
    color: var(--text);
}

.chat-bubble--error {
    border-color: rgba(var(--danger-rgb), 0.35);
    background: rgba(var(--danger-rgb), 0.08);
    color: var(--danger-soft);
}

/* Loading / typing indicator */
.chat-bubble--loading {
    padding: 1rem 1.25rem;
}

.chat-typing {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30%           { opacity: 1;   transform: scale(1); }
}

/* ── Chat Input Row ────────────────────────────────────────────────── */
.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    padding: 0.6rem 0.85rem;
    line-height: 1.5;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input:focus {
    border-color: var(--coach);
    box-shadow: 0 0 0 3px rgba(var(--coach-rgb), 0.18);
}

.chat-input::placeholder {
    color: var(--text-placeholder);
}

.chat-send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-md);
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-input-counter-row {
    display: flex;
    justify-content: flex-end;
}

.coach-input-counter {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-ui);
}

.coach-input-counter.at-limit {
    color: var(--warning);
    font-weight: 600;
}

/* ── Profile Page ──────────────────────────────────────────────────── */
.profile-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

.profile-page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.profile-page-icon {
    font-size: 2.2rem;
    color: var(--coach);
    margin-bottom: 0.5rem;
}

.profile-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.35rem;
}

.profile-page-desc {
    color: var(--text-ui-strong);
    font-size: 0.88rem;
    margin: 0;
}

.profile-subtab-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0 0 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.15rem;
}

.profile-subtab-nav::-webkit-scrollbar {
    height: 4px;
}

.profile-subtab-btn {
    flex: 0 0 auto;
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-ui-strong);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.profile-subtab-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent-hover);
}

.profile-subtab-btn--active,
.profile-subtab-btn.profile-subtab-btn--active {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.profile-subtab-panels {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.profile-subtab-panel .profile-card {
    margin: 0;
}

.profile-account-billing {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text);
}

.profile-account-billing p {
    margin: 0 0 0.5rem;
}

.profile-account-billing p:last-child {
    margin-bottom: 0;
}

.profile-account-meta,
.profile-account-note {
    font-size: 0.82rem;
    color: var(--text-ui-strong);
}

.profile-account-stripe {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.85rem;
}

.profile-account-placeholder {
    margin: 0;
    color: var(--text-ui-strong);
    font-size: 0.85rem;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.profile-card:last-child {
    grid-column: 1 / -1;
}

.profile-card--danger {
    border-color: rgba(var(--danger-rgb), 0.38);
}

.profile-danger-lead {
    font-size: 0.88rem;
    color: var(--coach-faint);
    margin: 0;
    line-height: 1.45;
}

.profile-delete-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    max-width: 32rem;
    width: min(32rem, calc(100vw - 2rem));
    max-height: min(90dvh, calc(100vh - 2rem));
    overflow-y: auto;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text);
    padding: 0;
    box-shadow: var(--shadow-card);
}

.profile-delete-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.profile-delete-dialog-inner {
    padding: 1.25rem 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.profile-delete-dialog-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.profile-delete-dialog-text {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--coach-faint);
}

.profile-delete-dialog-text code {
    font-size: 0.82em;
}

.profile-delete-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.profile-delete-dialog-actions--split {
    justify-content: space-between;
    margin-top: 0.25rem;
}

.profile-delete-dialog-actions--center {
    justify-content: center;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.profile-delete-export-btn {
    min-width: min(100%, 18rem);
    justify-content: center;
}

.profile-delete-announcer {
    min-height: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-sub);
    margin: 0;
}

.profile-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--coach-faint);
    margin: 0 0 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.profile-card-title .brand-logo--inline {
    width: 1.05rem;
    height: 1.05rem;
    object-fit: contain;
}

/* Account email: title + value + Change — do not flex-grow the inline block (avoids a huge gap before Change) */
.profile-email-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-width: 0;
}

.profile-card-title--email-row {
    margin: 0;
    flex-shrink: 0;
    color: var(--text-ui-strong);
}

.profile-email-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    margin-left: 1rem;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 520px) {
    .profile-email-inline {
        margin-left: 0;
    }
}

/* Account deletion: high-contrast danger CTA (default .btn-danger is intentionally soft) */
.profile-card--danger .profile-delete-open-btn:not(:disabled) {
    background: rgba(var(--danger-rgb), 0.92);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 14px rgba(var(--danger-rgb), 0.4);
    font-weight: 600;
}

.profile-card--danger .profile-delete-open-btn:not(:disabled):hover {
    background: rgb(248, 78, 78);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    box-shadow: 0 4px 20px rgba(var(--danger-rgb), 0.5);
}

.profile-card--danger .profile-delete-open-btn:not(:disabled):active {
    transform: scale(0.97);
}

.profile-delete-open-btn {
    margin-top: 0.35rem;
    margin-left: auto;
    align-self: flex-end;
    justify-content: center;
    text-align: center;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.profile-field input,
.profile-field select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.profile-field input:focus,
.profile-field select:focus {
    border-color: var(--coach);
    box-shadow: 0 0 0 3px rgba(var(--coach-rgb), 0.18);
}

.profile-age-display {
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 600;
    min-height: 1.2em;
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: flex-end;
}

.profile-save-status {
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 600;
}

.profile-save-status--error {
    color: var(--danger);
}

/* Onboarding-style controls inside profile (onboarding.css provides .ob-*) */
.profile-ob-fieldset {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.profile-ob-fieldset .ob-label {
    margin-bottom: 0.45rem;
}

.profile-ob-hint {
    font-size: 0.75rem;
    color: var(--text-ui-strong);
    margin: 0 0 0.5rem;
    line-height: 1.35;
}

.profile-ob-choice-grid {
    max-width: 100%;
}

.profile-ob-muscle-grid {
    max-width: 100%;
}

.profile-ob-pills-wrap .ob-pill {
    margin-bottom: 0.25rem;
}

.profile-field--date {
    flex-direction: column;
    align-items: stretch;
}

.profile-no-deadline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.45rem;
    font-size: 0.82rem;
    color: var(--text-ui-strong);
    cursor: pointer;
}

/* Matches onboarding “No specific deadline” row under target date */
.profile-ob-nested-deadline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.85rem;
    color: var(--text-ui-strong);
    cursor: pointer;
}

.profile-injuries-overflow-note {
    font-size: 0.72rem;
    color: var(--warning);
    margin: 0.35rem 0 0;
}

.ob-textarea--profile-injuries {
    margin-top: 0.5rem;
    min-height: 2.75rem;
}

@media (max-width: 720px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Coach Quota ──────────────────────────────────────────────────── */
.coach-quota {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-ui);
    padding: 0.55rem 0.85rem;
    background: rgba(var(--coach-rgb), 0.06);
    border: 1px solid rgba(var(--coach-rgb), 0.15);
    border-radius: var(--radius-sm);
}

.coach-quota i {
    color: var(--coach);
}

.coach-quota--low {
    color: var(--warning);
    border-color: rgba(var(--warning-rgb), 0.3);
    background: rgba(var(--warning-rgb), 0.06);
}

.coach-quota--low i {
    color: var(--warning);
}

.coach-quota--empty {
    color: var(--danger);
    border-color: rgba(var(--danger-rgb), 0.3);
    background: rgba(var(--danger-rgb), 0.06);
}

.coach-quota--empty i {
    color: var(--danger);
}

.coach-billing-banner {
    font-size: 0.85rem;
    color: var(--text);
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: rgba(var(--warning-rgb), 0.08);
}

.coach-billing-banner[hidden] {
    display: none !important;
}

.coach-billing-banner i {
    margin-right: 0.35rem;
    color: var(--warning);
}

/* Current block strip (cycle plan) */
.coach-cycle-strip {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-ui);
    padding: 0.45rem 0.85rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.coach-cycle-strip-text {
    color: var(--text-ui-strong);
    font-weight: 500;
}

/* Thin gold block progress (coach strip + History Weekly Volume header) */
.block-progress-wrap {
    width: 100%;
    min-height: 3px;
}

.block-progress-wrap[hidden] {
    display: none !important;
}

.block-progress-track {
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.block-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-dim), var(--accent));
    transition: width 0.28s ease;
}

/* ── Generate confirm banner ───────────────────────────────────────── */
.coach-confirm-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: rgba(200, 165, 116, 0.07);
    border: 1px solid rgba(200, 165, 116, 0.22);
    border-radius: var(--radius-sm);
    animation: fadeSlideDown 0.15s ease;
}

.coach-confirm-text {
    font-size: 0.82rem;
    color: var(--text-ui-strong);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.coach-confirm-text i {
    color: var(--accent-dim);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.coach-confirm-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.coach-confirm-actions .btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

@keyframes fadeSlideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .coach-confirm-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Profile email (head row + change form) ───────────────────────── */
.profile-email-value {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
}

.profile-email-change-btn {
    flex: 0 0 auto;
    box-sizing: border-box;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
}

.profile-email-change-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.65rem 0 0;
}

.profile-email-change-form input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.82rem;
    padding: 0.45rem 0.55rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.profile-email-change-form input:focus {
    border-color: var(--coach);
    box-shadow: 0 0 0 3px rgba(var(--coach-rgb), 0.18);
    outline: none;
}

.profile-email-hint {
    font-size: 0.78rem;
    color: var(--text-ui);
    margin: 0;
}

.profile-email-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.65rem;
}

.profile-email-action-btn {
    background: var(--coach);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    cursor: pointer;
    transition: background var(--transition);
}

.profile-email-action-btn:hover {
    background: var(--coach-deep);
}

.profile-email-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.profile-email-cancel-btn {
    background: none;
    border: none;
    color: var(--text-ui-muted);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.4rem 0.55rem;
    transition: color var(--transition);
}

.profile-email-cancel-btn:hover {
    color: var(--text);
}

.profile-email-status {
    font-size: 0.78rem;
    color: var(--text-ui);
    min-height: 1.1em;
}

.profile-email-status--error {
    color: var(--danger);
}

/* ── Profile Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-card:last-child {
        grid-column: auto;
    }

    .profile-page-title {
        font-size: 1.25rem;
    }
}

/* ── Coach Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* One quick action was sitting in the first of two 1fr columns (~half of actions). Single column fills the flex:2 strip beside quota. */
    .coach-actions {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .coach-quick {
        font-size: 0.72rem;
        padding: 0.55rem 0.5rem;
    }

    .btn.btn-primary.coach-quick--generate {
        width: 100%;
        min-height: 2.75rem;
        font-size: 0.8rem;
        padding: 0.7rem 1rem;
    }

    .chat-messages {
        min-height: 250px;
        max-height: 50vh;
        padding: 0.85rem;
    }

    .chat-bubble {
        max-width: 92%;
        font-size: 0.84rem;
    }
}

@media (max-width: 400px) {
    .btn.btn-primary.coach-quick--generate {
        min-height: 2.85rem;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   AI Coach UX — Enhanced Experience
   ══════════════════════════════════════════════════════════════════════ */

/* ── Thinking status label (shown while waiting for first token) ─────── */
.coach-thinking-status {
    display: block;
    font-size: 0.82rem;
    color: var(--text-ui);
    margin-bottom: 0.5rem;
    transition: opacity 0.2s ease;
}

.coach-thinking-status i {
    color: var(--coach);
    margin-right: 0.35rem;
    font-size: 0.78rem;
}

.coach-thinking-status .brand-logo--thinking {
    width: 0.85rem;
    height: 0.85rem;
    display: inline-block;
    vertical-align: -0.12em;
    margin-right: 0.35rem;
    object-fit: contain;
}

/* Program actions: structured output streams JSON in tokens — avoid painting partial JSON */
.coach-structured-stream-hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-ui);
    font-style: italic;
}

/* ── Coach loading full-panel (program + chat SSE) ─────────────────── */
.coach-gen-panel {
    align-self: stretch;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 0.5rem 0 0.25rem;
    box-sizing: border-box;
}

.coach-gen-panel__inner {
    text-align: center;
    max-width: 28rem;
    width: 100%;
    margin: 0 auto;
}

.coach-gen-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.85rem;
    padding: 4px 0;
}

.coach-gen-logo-wrap .brand-logo--coach-gen,
.coach-gen-logo-img {
    width: 88px;
    height: 88px;
    max-width: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 20px rgba(var(--coach-rgb), 0.22));
    transform-origin: center center;
}

@media (max-width: 480px) {
    .coach-gen-logo-wrap .brand-logo--coach-gen,
    .coach-gen-logo-img {
        width: 72px;
        height: 72px;
    }
}

/* Noticeable breathe (DEMO-like); disabled under prefers-reduced-motion below. */
@keyframes coachGenLogoBreathe {
    0%, 100% {
        opacity: 0.78;
        transform: scale(0.94);
    }
    50% {
        opacity: 1;
        transform: scale(1.07);
    }
}

.coach-gen-logo-wrap .brand-logo--coach-gen,
.coach-gen-logo-img {
    animation: coachGenLogoBreathe 2.2s ease-in-out infinite;
}

.coach-gen-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.65rem;
    line-height: 1.35;
}

.coach-gen-status {
    display: block;
    font-size: 0.86rem;
    color: var(--text-ui);
    margin: 0 0 0.65rem;
    min-height: 1.35em;
    transition: opacity 0.2s ease;
}

.coach-gen-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 0.65rem;
}

.coach-gen-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--coach-deep), var(--coach-mid), var(--coach-soft));
    transition: width 0.12s ease-out;
}

.coach-gen-stream {
    text-align: left;
    min-height: 1.25rem;
    max-height: 38vh;
    overflow-y: auto;
    font-size: 0.86rem;
    color: var(--text);
    line-height: 1.55;
    margin-bottom: 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-card) transparent;
}

.coach-gen-stream:empty {
    display: none;
}

.coach-gen-typing {
    justify-content: center;
    margin-top: 0.15rem;
}

.coach-gen-typing.coach-gen-typing--hidden {
    visibility: hidden;
    height: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}

/* OS / browser “reduce motion” (e.g. macOS Settings → Accessibility → Display,
   Windows Settings → Accessibility → Visual effects, Firefox ui.prefersReducedMotion)
   turns logo motion off by design; the activity bar still updates. */
@media (prefers-reduced-motion: reduce) {
    .coach-gen-logo-wrap .brand-logo--coach-gen,
    .coach-gen-logo-img,
    .ob-gen-icon--pulsing .brand-logo--ob-gen {
        animation: none !important;
        opacity: 1;
        transform: none;
    }
}

/* ── Enhanced markdown in coach responses ──────────────────────────── */
.coach-response-heading {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    margin: 0.6rem 0 0.3rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border-card);
}

.coach-response-list {
    padding-left: 1.1rem;
    margin: 0.35rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    list-style: none;
}

.coach-response-list li {
    position: relative;
    padding-left: 0.9rem;
    font-size: 0.86rem;
    color: var(--text-sub);
    line-height: 1.55;
}

.coach-response-list li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: var(--accent-dim);
    font-weight: 600;
}

.coach-response-spacer {
    height: 0.5rem;
}

/* ── Program card: base + animated reveal ──────────────────────────── */
.program-preview {
    background: var(--bg-card);
    border: 1px solid rgba(var(--coach-rgb), 0.3);
    border-radius: var(--radius-lg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.program-preview--visible {
    opacity: 1;
    transform: translateY(0);
}

.program-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1.15rem;
    background: rgba(var(--coach-rgb), 0.08);
    border-bottom: 1px solid rgba(var(--coach-rgb), 0.2);
    flex-wrap: wrap;
}

.program-preview-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--coach-faint);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.program-preview-title .brand-logo--inline {
    width: 1rem;
    height: 1rem;
    object-fit: contain;
}

.program-preview-body {
    padding: 1rem 1.15rem;
    font-size: 0.84rem;
    color: var(--text-sub);
    max-height: 300px;
    overflow-y: auto;
}

/* ── Program card: summary strip (chips row) ────────────────────────── */
.program-preview-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.7rem 1.15rem;
    background: rgba(var(--coach-rgb), 0.04);
    border-bottom: 1px solid rgba(var(--coach-rgb), 0.12);
}

.preview-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: rgba(var(--coach-rgb), 0.1);
    border: 1px solid rgba(var(--coach-rgb), 0.2);
    color: var(--coach-faint);
    white-space: nowrap;
}

.preview-chip i {
    font-size: 0.68rem;
    opacity: 0.8;
}

.preview-chip--title {
    background: rgba(200, 165, 116, 0.08);
    border-color: rgba(200, 165, 116, 0.2);
    color: var(--accent);
}

.preview-chip--deload {
    background: rgba(var(--warning-rgb), 0.1);
    border-color: rgba(var(--warning-rgb), 0.25);
    color: var(--warning-soft);
}

.preview-chip--info {
    background: rgba(var(--info-rgb), 0.08);
    border-color: rgba(var(--info-rgb), 0.2);
    color: var(--info);
}

/* ── Program card: footer with apply CTA ───────────────────────────── */
.program-preview-footer {
    padding: 0.85rem 1.15rem;
    background: rgba(var(--coach-rgb), 0.04);
    border-top: 1px solid rgba(var(--coach-rgb), 0.12);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.program-preview-apply {
    font-size: 0.9rem;
    padding: 0.65rem 1.4rem;
    letter-spacing: 0.01em;
    transition: background var(--transition), transform 0.15s ease, box-shadow var(--transition);
}

.program-preview-apply:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(var(--coach-rgb), 0.3);
}

.program-preview-apply:active:not(:disabled) {
    transform: translateY(0);
}

.program-apply-btn--success {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: #fff !important;
}

.program-preview-dismiss {
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
    color: var(--text-ui);
    border-color: transparent;
}

.program-preview-dismiss:hover {
    color: var(--text-sub);
    border-color: var(--border-card);
}

/* ── Enhanced preview session cards ─────────────────────────────────── */
.preview-sessions {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.preview-session {
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease;
}

.preview-session:hover {
    border-color: rgba(var(--coach-rgb), 0.2);
}

.preview-session--deload {
    border-color: rgba(var(--warning-rgb), 0.2);
    background: rgba(var(--warning-rgb), 0.03);
}

.preview-session-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
}

.preview-session-day {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--coach);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 2.2rem;
}

.preview-session-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.preview-session-emphasis {
    font-size: 0.72rem;
    color: var(--accent-dim);
    background: var(--bg-badge);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    margin-left: auto;
}

/* ── Enhanced preview exercise rows ─────────────────────────────────── */
.preview-exercises {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.preview-exercises li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-sub);
    padding: 0.28rem 0;
    border-bottom: 1px solid rgba(48, 38, 22, 0.6);
    flex-wrap: wrap;
}

.preview-exercises li:last-child {
    border-bottom: none;
}

.preview-ex-name {
    color: var(--text);
    font-weight: 500;
    flex: 1;
    min-width: 140px;
}

.preview-ex-load {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.74rem;
    white-space: nowrap;
}

/* ── Visual handoff divider (between coaching text and program card) ── */
.coach-program-divider {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.2rem 0;
    animation: bubbleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.coach-program-divider::before,
.coach-program-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(var(--coach-rgb), 0.25), transparent);
}

.coach-program-divider span {
    font-size: 0.72rem;
    color: var(--coach);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.coach-program-divider i {
    font-size: 0.65rem;
    animation: subtleBounce 1.5s ease infinite;
}

@keyframes subtleBounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(3px); }
}

/* ── Responsive adjustments for new elements ───────────────────────── */
@media (max-width: 600px) {
    .program-preview-summary-strip {
        padding: 0.5rem 0.85rem;
    }

    .program-preview-footer {
        padding: 0.65rem 0.85rem;
    }

    .program-preview-apply {
        width: 100%;
        justify-content: center;
    }

    .preview-session-header {
        gap: 0.35rem;
    }

    .preview-session-emphasis {
        margin-left: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════ */

@media print {
    :root {
        --bg:         #ffffff;
        --bg-card:    #ffffff;
        --bg-elevated: #f5f5f5;
        --bg-input:   #fafafa;
        --text:       #1a1a1a;
        --text-sub:   #444;
        --text-muted: #666;
        --text-faint: #999;
        --text-ui:        #555;
        --text-ui-muted:  #666;
        --text-ui-strong: #333;
        --text-placeholder: #777;
        --accent:     #9a7040;
        --accent-hover: #b8926a;
        --accent-muted: rgba(154, 112, 64, 0.28);
        --border:     #ddd;
        --border-card: #ccc;
    }

    body {
        display: block;
        min-height: 0;
        background: #fff;
        color: #1a1a1a;
    }

    .main-content {
        flex: none;
    }

    .site-header {
        position: static;
        flex-shrink: unset;
        border-bottom: 2px solid #ccc;
        backdrop-filter: none;
        background: #fff;
    }

    .header-actions,
    .save-toast,
    .site-footer,
    .coach-container {
        display: none !important;
    }

    .tab-nav {
        display: none;
    }

    /* Hide profile + coach tab sections in print */
    .tab-btn-coach,
    .tab-btn-profile { display: none !important; }
    .profile-page,
    .coach-container { display: none !important; }

    .tab-content {
        display: block !important;
        animation: none !important;
    }

    .exercise-card {
        animation: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
        margin-bottom: 0.75rem;
    }

    .exercise-card:hover {
        transform: none;
        border-left-color: #ccc;
        background: #fff;
    }

    .exercise-info-btn {
        display: none !important;
    }

    .set-row {
        animation: none !important;
    }

    .set-row select.set-reps-select,
    .set-row select.set-rpe-select,
    .set-row select.set-performed-count-select {
        appearance: auto;
        background-image: none;
        padding-right: 0.35rem;
        color: #1a1a1a;
        border: 1px solid #ccc;
        background-color: #fafafa;
    }

    .set-remove-btn,
    .btn-add-set {
        display: none !important;
    }

    .coach-notes,
    .coach-notes p,
    .coach-notes[open] p {
        display: block !important;
    }

    .coach-notes summary {
        display: none;
    }

    input[type="text"],
    textarea {
        border: 1px solid #bbb;
        background: #fafafa;
        color: #1a1a1a;
    }

    .overview-hero {
        background: #f9f9f9;
        border: 1px solid #ccc;
    }

    .session-header {
        border-bottom: 1px solid #ccc;
    }

    .overview-hero::before {
        display: none;
    }

    .overview-icon {
        animation: none;
    }

    h1, h2 {
        color: #1a1a1a;
    }

    .prescribed-badge {
        border: 1px solid var(--accent);
        color: var(--accent);
        background: transparent;
    }

    .exercise-schema-badge {
        border: 1px solid #6b4f8f;
        color: #4a3568;
        background: rgba(107, 79, 143, 0.12);
    }

    .rest-badge {
        border: 1px solid #3a8a9e;
        color: #1a5f6e;
        background: rgba(50, 140, 160, 0.1);
    }

    .stat-card, .session-pill {
        background: #f5f5f5;
        border: 1px solid #ddd;
    }
}

/* ── Pre-generate feedback modal ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 1rem;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    max-width: 420px;
    width: 100%;
    padding: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-sub);
    margin-bottom: 1.25rem;
}

.feedback-field {
    margin-bottom: 1rem;
}

.feedback-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.feedback-field .optional {
    font-weight: normal;
    color: var(--text-ui);
}

.rating-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.rating-btn {
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.rating-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card);
}

.rating-btn.selected {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--text);
}

/* Star rating: 5 stars in a row, click to set 1–5; filled stars use accent */
.star-rating {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.star-rating__star {
    padding: 0.35rem;
    border: none;
    background: transparent;
    color: var(--text-ui);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition), transform var(--transition);
}

.star-rating__star .fa-star {
    font-size: 1.35rem;
    display: block;
}

.star-rating__star:hover {
    color: var(--accent-dim);
}

.star-rating__star.filled {
    color: var(--accent);
}

.rating-btn:focus-visible,
.star-rating__star:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.feedback-field input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9375rem;
}

.feedback-field select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9375rem;
    cursor: pointer;
    min-width: 6rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.feedback-field select:hover {
    border-color: var(--border-card);
}

.feedback-field select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.feedback-field input[type="text"]:focus,
.feedback-field input[type="number"]:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.feedback-field input[type="number"] {
    width: 6rem;
    margin-right: 0.25rem;
}

.feedback-unit {
    font-size: 0.9rem;
    color: var(--text-ui);
}

.feedback-missed-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.feedback-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-weight: normal;
}

.feedback-missed-sessions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.feedback-missed-sessions label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ── Exercise instructions modal (catalog) ─────────────────────────── */
.exercise-instructions-overlay {
    z-index: 1001;
}

.modal-card--instructions {
    position: relative;
    max-width: 36rem;
    max-height: min(85vh, 42rem);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.exercise-instructions-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.35rem 0.85rem 1.25rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.exercise-instructions-modal-title {
    margin: 0;
    flex: 1;
    min-width: 0;
    padding-right: 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
    letter-spacing: -0.02em;
}

.exercise-instructions-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-ui);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.exercise-instructions-close:hover {
    color: var(--text);
    background: var(--bg-card-hover);
}

.exercise-instructions-close:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.exercise-instructions-body {
    padding: 1rem 1.25rem 1.35rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.exercise-instructions-steps {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.55;
}

.exercise-instructions-steps li {
    margin-bottom: 0.65rem;
    padding-left: 0.25rem;
}

.exercise-instructions-steps li:last-child {
    margin-bottom: 0;
}

.exercise-instructions-notes {
    margin: 1rem 0 0;
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-sub);
    font-size: 0.9rem;
    font-style: italic;
    line-height: 1.5;
}

.exercise-instructions-notes[hidden] {
    display: none !important;
}

/* ── History & Stats Page ──────────────────────────────────────────── */
.history-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem 0;
}

.history-page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.history-page-icon {
    font-size: 2.2rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.history-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.35rem;
}

.history-page-desc {
    color: var(--text-ui-strong);
    font-size: 0.88rem;
    margin: 0;
}

/* Loading state inside the history panel */
.history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: var(--text-ui);
    font-size: 0.9rem;
}

.history-error {
    color: var(--danger-ink);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

/* ── Stats Strip ─────────────────────────────────────────────────── */
.history-stats-strip {
    display: grid;
    /* Three equal columns for the metric cards; PR row uses .history-stat-card--wide */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.history-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    transition: border-color var(--transition);
}

.history-stat-card:hover {
    border-color: var(--accent-muted);
}

.history-stat-card--wide {
    grid-column: 1 / -1;
}

.history-stat-icon {
    font-size: 1.1rem;
    color: var(--accent-dim);
    margin-bottom: 0.15rem;
}

.history-stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.15;
}

.history-stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-ui);
}

/* PRs inside the wide stat card */
.history-stat-prs {
    margin-top: 0.35rem;
}

.history-pr-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.history-pr-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.88rem;
    flex-wrap: wrap;
}

.history-pr-ex {
    color: var(--text-ui);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-pr-val {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Chart Cards ─────────────────────────────────────────────────── */
.history-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    transition: border-color var(--transition);
}

.history-chart-card:hover {
    border-color: var(--border-card);
}

.history-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.history-chart-header--stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.history-chart-header--stacked .history-chart-title {
    margin-bottom: 0;
}

.history-chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.history-chart-title i {
    color: var(--accent-dim);
}

.history-chart-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* Exercise dropdown */
.history-select {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 240px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.history-select:hover {
    border-color: var(--accent-muted);
}

.history-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

/* Metric toggle buttons */
.history-metric-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-metric-btn {
    padding: 0.3rem 0.7rem;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-ui);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.history-metric-btn + .history-metric-btn {
    border-left: 1px solid var(--border);
}

.history-metric-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-sub);
}

.history-metric-btn--active {
    background: var(--accent-muted);
    color: var(--text);
}

.history-metric-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Chart canvas wrapper */
.history-chart-wrap {
    position: relative;
    height: 240px;
}

.history-chart-empty {
    text-align: center;
    color: var(--text-ui);
    font-size: 0.875rem;
    padding: 2rem 1rem;
    margin: 0;
}

/* ── Training Log Card ───────────────────────────────────────────── */
.history-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Year filter — same visual language as .history-metric-toggle */
.history-year-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.history-year-btn {
    padding: 0.3rem 0.75rem;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-ui);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.history-year-btn + .history-year-btn { border-left: 1px solid var(--border); }
.history-year-btn:hover               { background: var(--bg-card-hover); color: var(--text-sub); }
.history-year-btn--active             { background: var(--accent-muted); color: var(--text); }
.history-year-btn:focus-visible       { outline: none; box-shadow: var(--shadow-focus); }

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

.history-log-card .history-chart-title {
    margin-bottom: 0;
}

.history-log-empty {
    color: var(--text-ui);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem 0;
    margin: 0;
}

/* ── Week Accordion ──────────────────────────────────────────────── */
.history-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-week {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition);
}

.history-week--open {
    border-color: var(--accent-muted);
}

.history-week-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: none;
    background: var(--bg-elevated);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
}

.history-week-btn:hover {
    background: var(--bg-card-hover);
}

.history-week-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.history-week-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.history-week-label i {
    color: var(--accent-dim);
}

.history-week-chevron {
    color: var(--text-ui);
    font-size: 0.8rem;
    transition: transform var(--transition);
    flex-shrink: 0;
}

.history-week--open .history-week-chevron {
    transform: rotate(180deg);
}

.history-week-body {
    padding: 0.75rem 1rem 1rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.history-week-subtitle {
    font-size: 0.8rem;
    color: var(--text-ui);
    margin: 0 0 0.75rem;
    font-style: italic;
}

/* Loading spinner inside week body */
.history-week-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    color: var(--text-sub);
    font-size: 0.875rem;
}

.app-loading-spinner--sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

/* ── Sessions inside an expanded week ────────────────────────────── */
.history-sessions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-session {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-session-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    background: rgba(200, 165, 116, 0.06);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.history-session-day {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--bg-badge);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
}

.history-session-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.history-session-tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-muted);
    color: var(--text);
}

.history-tag-strength   { background: rgba(var(--info-rgb),0.25);  color: var(--info); }
.history-tag-hypertrophy{ background: rgba(200, 165, 116, 0.25);  color: var(--accent); }
.history-tag-metabolic  { background: rgba(52,211,153,0.20);  color: #6ee7b7; }

/* ── Exercise rows inside a session ─────────────────────────────── */
.history-exercise-list {
    display: flex;
    flex-direction: column;
}

.history-exercise-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem 0.75rem;
    align-items: start;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

/* Desktop: name (left) + set chips (right, same row); notes full width below when present */
.history-exercise-row:not(.history-exercise-row--has-notes) {
    grid-template-areas:
        "exname exdata";
}

.history-exercise-row--has-notes {
    grid-template-areas:
        "exname exdata"
        "exnotes exnotes";
}

.history-exercise-row:last-child {
    border-bottom: none;
}

.history-ex-name {
    grid-area: exname;
    font-size: 0.88rem;
    color: var(--text-sub);
    min-width: 0;
}

.history-ex-notes {
    grid-area: exnotes;
    font-size: 0.78rem;
    color: var(--text-ui);
    font-style: italic;
    line-height: 1.35;
    padding-top: 0.1rem;
}

.history-ex-data {
    grid-area: exdata;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    min-width: 0;
    justify-self: end;
}

/* Set chips (archived log); grouped runs use .history-set-chip--group */
.history-set-chip {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem 0.35rem;
    font-size: 0.78rem;
    line-height: 1.35;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    background: var(--bg-badge);
    border: 1px solid var(--border);
    color: var(--text-sub);
}

.history-set-chip--group {
    gap: 0.15rem 0.3rem;
}

.history-set-count {
    font-weight: 700;
    color: var(--accent-dim);
    font-size: 0.76rem;
}

.history-set-w {
    font-weight: 600;
    color: var(--text);
}

.history-set-sep {
    opacity: 0.45;
    font-weight: 400;
}

.history-set-rpe {
    font-weight: 600;
    color: var(--accent-dim);
    font-size: 0.76rem;
}

.history-weight {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.history-reps {
    font-size: 0.85rem;
    color: var(--text-sub);
}

.history-rpe {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-dim);
    background: var(--bg-badge);
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-sm);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .history-exercise-row--has-notes {
        grid-template-columns: 1fr;
        grid-template-areas:
            "exname"
            "exdata"
            "exnotes";
    }

    .history-exercise-row:not(.history-exercise-row--has-notes) {
        grid-template-columns: 1fr;
        grid-template-areas:
            "exname"
            "exdata";
    }

    .history-ex-notes {
        text-align: left;
        max-width: none;
        justify-self: stretch;
        font-size: 0.8rem;
        padding-top: 0.15rem;
    }

    .history-exercise-row .history-ex-data {
        justify-self: stretch;
        justify-content: flex-start;
    }

    .history-stats-strip {
        grid-template-columns: 1fr 1fr;
    }

    .history-chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-chart-controls {
        width: 100%;
    }

    .history-select {
        max-width: 100%;
        width: 100%;
    }

    .history-chart-wrap {
        height: 200px;
    }
}

/* ── Auth pages (login, register, forgot/reset password) ───────────────
   Standalone pages: body uses column flex from base styles; .login-wrap
   fills space so the card stays vertically centered. */
.login-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.5rem;
    box-sizing: border-box;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.login-card--narrow {
    max-width: 360px;
}

.login-icon {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-icon .brand-logo--login {
    width: 112px;
    height: 112px;
    margin: 0 auto;
    display: block;
    object-fit: contain;
}

@media (max-width: 480px) {
    .login-icon .brand-logo--login {
        width: 92px;
        height: 92px;
    }
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.login-field label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-ui);
}

.login-field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 1rem;
    padding: 0.65rem 0.85rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-error {
    background: rgba(var(--danger-rgb), 0.12);
    border: 1px solid rgba(var(--danger-rgb), 0.35);
    border-radius: var(--radius-md);
    color: var(--danger-soft);
    font-size: 0.88rem;
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-success {
    background: rgba(var(--success-rgb), 0.12);
    border: 1px solid rgba(var(--success-rgb), 0.35);
    border-radius: var(--radius-md);
    color: var(--success-soft);
    font-size: 0.88rem;
    padding: 0.6rem 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-success--wide {
    align-items: flex-start;
    line-height: 1.45;
    font-size: 0.82rem;
}

.login-submit {
    width: 100%;
    margin-top: 0.5rem;
    justify-content: center;
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

.login-links {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-links a {
    color: var(--accent);
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

.form-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.form-hint {
    text-align: center;
    color: var(--text-ui);
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
}

.verify-hint {
    text-align: center;
    color: var(--text-ui);
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.verify-code-input {
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 0.3em;
    font-weight: 700;
}

.resend-row {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

.resend-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
}

.resend-btn:hover {
    text-decoration: underline;
}
