:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f5f7fb;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
.container { width: min(1040px, calc(100% - 32px)); margin: 0 auto; }
.narrow { width: min(680px, calc(100% - 32px)); }
.topbar { background: #111827; color: white; padding: 16px 0; margin-bottom: 36px; }
.topbar-inner { display: flex; gap: 14px; align-items: baseline; }
.brand { font-size: 22px; font-weight: 800; text-decoration: none; letter-spacing: .08em; }
.muted { color: #6b7280; }
.topbar .muted { color: #9ca3af; }
h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 42px); }
h2 { margin: 0 0 16px; }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 28px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.button { appearance: none; border: 0; border-radius: 10px; background: #2563eb; color: white; padding: 10px 15px; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.button:hover { filter: brightness(.96); }
.button.secondary { background: white; color: #172033; border: 1px solid #d1d5db; }
.button.danger { background: #b91c1c; }
.button.small { padding: 9px 12px; }
.panel, .exercise-card, .workout-card, .empty-state { background: white; border: 1px solid #e5e7eb; border-radius: 14px; box-shadow: 0 4px 14px rgba(15,23,42,.04); }
.panel { padding: 22px; margin-bottom: 22px; }
.workout-list { display: grid; gap: 12px; }
.workout-card { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; text-decoration: none; }
.workout-card:hover { border-color: #93c5fd; }
.empty-state { padding: 56px 24px; text-align: center; }
.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-weight: 600; }
input, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 10px 12px; font: inherit; background: white; }
input:focus, textarea:focus { outline: 3px solid #dbeafe; border-color: #2563eb; }
textarea { resize: vertical; }
.field-error { color: #b91c1c; font-size: 14px; font-weight: 500; }
.back-link { display: inline-block; margin-bottom: 18px; color: #4b5563; text-decoration: none; }
.comment p { margin-bottom: 0; white-space: pre-wrap; }
.exercise-card { padding: 22px; margin: 18px 0; }
.exercise-heading { display: flex; justify-content: space-between; gap: 16px; }
.link-danger { border: 0; background: none; color: #b91c1c; cursor: pointer; padding: 4px; font: inherit; }
table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef2f7; }
th { color: #6b7280; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.align-right { text-align: right; }
.inline-form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.inline-form label { min-width: 130px; }
.grow { flex: 1 1 280px; }
.full-width { flex-basis: 100%; }
.add-exercise { margin-top: 28px; }
@media (max-width: 700px) {
    .page-heading { flex-direction: column; }
    .actions { width: 100%; }
    .actions .button, .actions form { flex: 1; }
    .actions form .button { width: 100%; }
    .exercise-heading { align-items: flex-start; }
}

/* Authentication, profile and multi-user navigation */
.nav { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.nav a, .nav-button { color: #475569; text-decoration: none; font: inherit; font-weight: 600; }
.nav a:hover, .nav a.active { color: #0f172a; }
.nav form { margin: 0; }
.nav-button { border: 0; background: transparent; cursor: pointer; padding: 4px 0; }
.nav-button:hover { color: #b91c1c; }
.auth-page { min-height: 100vh; background: #f1f5f9; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 460px); background: white; border: 1px solid #e2e8f0; border-radius: 18px; padding: 32px; box-shadow: 0 14px 40px rgba(15,23,42,.08); }
.brand.large { display: inline-block; font-size: 28px; margin-bottom: 16px; }
.auth-footer { margin-top: 22px; text-align: center; color: #64748b; }
.alert { padding: 12px 14px; border-radius: 10px; margin: 0 0 18px; }
.alert.success { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.panel.subtle { background: #f8fafc; color: #475569; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.measurements { grid-template-columns: repeat(3, minmax(0, 1fr)); }
select { width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 10px 12px; font: inherit; background: white; }
select:focus { outline: 3px solid #dbeafe; border-color: #2563eb; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: white; border: 1px solid #e2e8f0; border-radius: 14px; padding: 18px; }
.stat-card > span, .profile-details > div > span { display: block; color: #64748b; font-size: 13px; margin-bottom: 6px; }
.stat-card strong { font-size: 22px; }
.profile-details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.profile-details strong { display: block; }
.table-scroll { overflow-x: auto; }
.actions.center { justify-content: center; }
@media (max-width: 800px) {
    .stats-grid, .profile-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.two, .form-grid.measurements { grid-template-columns: 1fr; }
    .topbar-inner { align-items: flex-start; gap: 12px; }
    .nav { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 520px) {
    .stats-grid, .profile-details { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 18px; }
}

/* Mobile-first polish and partial page updates */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    min-width: 0;
    overflow-x: hidden;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}
button, input, select, textarea { touch-action: manipulation; }
.button, .nav-button, .link-danger { -webkit-tap-highlight-color: transparent; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.icon-button { min-width: 44px; min-height: 44px; font-size: 24px; line-height: 1; }
form.is-busy { pointer-events: none; }
form.is-busy button { cursor: progress; }

@media (max-width: 700px) {
    .container, .narrow { width: calc(100% - 28px); }
    .topbar {
        padding: max(12px, env(safe-area-inset-top)) 0 12px;
        margin-bottom: 24px;
    }
    .topbar-inner { align-items: center; }
    .brand { flex: 0 0 auto; }
    .nav { min-width: 0; }
    .nav a, .nav-button { min-height: 40px; display: inline-flex; align-items: center; }
    .nav a:nth-child(2) {
        max-width: 34vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    h1 { font-size: clamp(28px, 9vw, 38px); line-height: 1.08; }
    h2 { font-size: 20px; }
    .page-heading { gap: 16px; margin-bottom: 20px; }
    .page-heading > div:first-child { min-width: 0; }
    .page-heading .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .page-heading .actions > * { min-width: 0; }
    .page-heading .actions .button { width: 100%; padding-left: 10px; padding-right: 10px; text-align: center; }
    .page-heading .actions form:last-child:nth-child(odd) { grid-column: 1 / -1; }

    .panel, .exercise-card { padding: 16px; border-radius: 12px; }
    .exercise-card { margin: 14px 0; }
    .exercise-heading { gap: 10px; align-items: flex-start; }
    .exercise-heading h2 { overflow-wrap: anywhere; }
    .exercise-heading .link-danger { padding: 2px 0; min-height: 40px; white-space: nowrap; }

    input, textarea, select { font-size: 16px; min-height: 46px; }
    textarea { min-height: 100px; }
    .inline-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
    .inline-form label { min-width: 0; width: 100%; }
    .inline-form .button { grid-column: 1 / -1; width: 100%; }
    .inline-form .full-width { grid-column: 1 / -1; }
    .add-exercise .inline-form { grid-template-columns: 1fr; }
    .add-exercise .inline-form > * { grid-column: 1; }

    .workout-card { padding: 16px; gap: 12px; }
    .workout-card > div { min-width: 0; }
    .workout-card strong { display: block; overflow-wrap: anywhere; }
    .workout-card > span { flex: 0 0 auto; font-size: 14px; }

    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card strong { font-size: 20px; }
    .profile-details { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

    .table-scroll { overflow: visible; }
    .responsive-table, .responsive-table tbody { display: block; width: 100%; }
    .responsive-table thead { display: none; }
    .responsive-table tr { display: block; }
    .responsive-table td { border: 0; }

    .sets-table { margin: 8px 0 14px; }
    .sets-table thead {
        display: block;
        width: 100%;
    }
    .sets-table thead tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) 76px;
        align-items: end;
        border: 0;
        padding: 0 0 5px;
    }
    .sets-table thead th {
        display: block;
        padding: 0 5px;
        border: 0;
        color: #64748b;
        font-size: 11px;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: .035em;
        white-space: nowrap;
    }
    .sets-table thead th:last-child { padding: 0; }
    .sets-table tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) 76px;
        align-items: center;
        border-top: 1px solid #eef2f7;
        padding: 9px 0;
    }
    .sets-table td { padding: 4px 5px; min-width: 0; }
    .sets-table td::before { display: none; content: none; }
    .sets-table td:last-child { padding: 0; }
    .sets-table td:last-child form { display: flex; justify-content: flex-end; }
    .sets-table .set-actions {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        white-space: nowrap;
    }

    .measurements-table { margin: 0; }
    .measurements-table tbody { display: grid; gap: 10px; }
    .measurements-table tr {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 10px 12px;
    }
    .measurements-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: 7px 0;
        border-bottom: 1px solid #e2e8f0;
        text-align: right;
    }
    .measurements-table td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 13px;
        font-weight: 600;
        text-align: left;
    }
    .measurements-table td:last-child { border-bottom: 0; justify-content: flex-end; }
    .measurements-table td:last-child::before { display: none; }
}

@media (max-width: 480px) {
    .container, .narrow { width: calc(100% - 24px); }
    .topbar-inner { display: grid; grid-template-columns: 1fr; gap: 6px; }
    .brand { justify-self: start; }
    .nav { width: 100%; margin-left: 0; justify-content: space-between; gap: 8px; }
    .nav a, .nav-button { font-size: 14px; }
    .nav a:nth-child(2) { max-width: 42vw; }
    .page-heading .actions { width: 100%; }
    .page-heading .actions > .button:only-child { grid-column: 1 / -1; }
    .actions.center { display: grid; grid-template-columns: 1fr; }
    .actions.center .button { width: 100%; }
    .empty-state { padding: 36px 16px; }
    .profile-details { grid-template-columns: 1fr; }
    .auth-shell { padding: 16px 12px max(16px, env(safe-area-inset-bottom)); }
    .auth-card { border-radius: 14px; }
}


/* iPhone / compact layout fixes */
.auth-card {
    max-width: 460px;
    margin-inline: auto;
}

@media (max-width: 820px) {
    .topbar {
        padding: max(14px, env(safe-area-inset-top)) 0 14px;
        margin-bottom: 24px;
    }

    .topbar-inner {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 12px;
    }

    .brand {
        justify-self: start;
        line-height: 1.15;
    }

    .nav {
        width: 100%;
        margin-left: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        align-items: stretch;
    }

    .nav > a,
    .nav > form {
        min-width: 0;
        width: 100%;
    }

    .nav > a,
    .nav-button {
        width: 100%;
        min-height: 44px;
        padding: 9px 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
        line-height: 1.15;
    }

    .nav > a {
        background: rgba(255,255,255,.08);
        color: #e5e7eb;
    }

    .nav > a:hover,
    .nav > a.active {
        background: rgba(255,255,255,.15);
        color: #fff;
    }

    .nav-button {
        border: 1px solid rgba(255,255,255,.18);
        background: transparent;
        color: #e5e7eb;
    }

    .nav a:nth-child(2) {
        max-width: none;
    }

    .page-heading .actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-heading .actions > .button:last-child {
        grid-column: 1 / -1;
    }

    .stats-grid,
    .profile-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-card,
    .profile-details > div {
        min-width: 0;
    }

    .profile-details strong,
    .stat-card strong {
        overflow-wrap: anywhere;
    }

    .profile-details {
        padding: 16px;
    }

    .table-scroll {
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .measurements-table,
    .measurements-table tbody,
    .measurements-table tr {
        width: 100%;
        max-width: 100%;
    }

    .measurements-table {
        table-layout: fixed;
    }

    .measurements-table thead {
        display: none;
    }

    .measurements-table tbody {
        display: grid;
        gap: 12px;
    }

    .measurements-table tr {
        display: grid;
        grid-template-columns: 1fr;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 8px 12px;
        overflow: hidden;
    }

    .measurements-table td {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 8px 0;
        border: 0;
        border-bottom: 1px solid #e2e8f0;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .measurements-table td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: #64748b;
        font-size: 13px;
        font-weight: 700;
        text-align: left;
    }

    .measurements-table td:last-child {
        border-bottom: 0;
        justify-content: flex-end;
    }

    .measurements-table td:last-child::before {
        display: none;
    }

    .measurements-table td:last-child form,
    .measurements-table td:last-child .link-danger {
        width: auto;
        max-width: 100%;
    }
}

@media (max-width: 520px) {
    .container,
    .narrow {
        width: calc(100% - 32px);
    }

    .auth-shell {
        min-height: 100svh;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding: max(28px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    }

    .auth-card {
        width: 100%;
        max-width: 430px;
        margin: 0 auto;
        padding: 24px 20px;
        border-radius: 16px;
    }

    .auth-card h1 {
        font-size: 32px;
    }

    .auth-footer {
        line-height: 1.45;
    }

    .nav {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(72px, .8fr);
    }

    .page-heading .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .page-heading .actions .button {
        min-height: 48px;
        padding: 11px 10px;
    }

    .page-heading .actions > .button:last-child {
        grid-column: 1 / -1;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .profile-details {
        grid-template-columns: 1fr;
    }

    #measurement-form .button {
        width: 100%;
    }
}

@media (max-width: 390px) {
    .container,
    .narrow {
        width: calc(100% - 24px);
    }

    .nav > a,
    .nav-button {
        font-size: 13px;
        padding-inline: 6px;
    }

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

/* Progress & personal records */
.progress-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.progress-list { display: grid; gap: 14px; }
.progress-card {
    display: block;
    padding: 20px;
    color: inherit;
    text-decoration: none;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(15,23,42,.04);
}
.progress-card:hover { border-color: #93c5fd; }
.progress-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.progress-card-heading h2 { margin-bottom: 4px; }
.progress-open { flex: 0 0 auto; font-size: 14px; }
.record-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.record-grid > div,
.record-card {
    min-width: 0;
    padding: 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}
.record-grid > div > span,
.record-card > span,
.record-card small {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 5px;
}
.record-grid strong,
.record-card strong {
    display: block;
    font-size: 20px;
    overflow-wrap: anywhere;
}
.record-grid strong { white-space: nowrap; }
.record-grid strong > span,
.stat-card strong > span { display: inline; margin: 0; color: inherit; font: inherit; }
.record-card small { margin: 5px 0 0; }
.records-main { margin-bottom: 20px; }
.positive { color: #15803d; }
.negative { color: #b91c1c; }
.progress-change {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
.progress-change strong { display: block; margin-top: 6px; font-size: 20px; }
.progress-delta { flex: 0 0 auto; font-size: 26px; font-weight: 800; white-space: nowrap; }
.progress-hint { margin-top: -6px; }
.progress-history { display: grid; gap: 10px; }
.progress-session {
    display: block;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
    background: #fff;
}
.progress-session:hover { border-color: #93c5fd; }
.progress-session-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}
.progress-session-head > div { min-width: 0; }
.progress-session-head strong,
.progress-session-head span { display: block; }
.progress-session-head .muted { overflow-wrap: anywhere; }
.session-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.session-metrics > div {
    position: relative;
    min-width: 0;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 10px;
}
.session-metrics > div > span { display: block; color: #64748b; font-size: 12px; margin-bottom: 4px; }
.session-metrics strong { display: inline; color: #0f172a; font-size: 17px; font-weight: 800; white-space: nowrap; }
.pr-badge {
    display: inline-flex;
    margin-top: 7px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    letter-spacing: .04em;
}

@media (max-width: 820px) {
    .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .nav a:nth-child(2), .nav a:nth-child(3) { max-width: none; }
    .progress-overview-grid,
    .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav > a,
    .nav > form { width: 100%; }
    .nav a:nth-child(2), .nav a:nth-child(3) { max-width: none; }
    .progress-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .progress-card { padding: 16px; }
    .progress-card-heading { display: grid; gap: 8px; }
    .progress-open { justify-self: start; }
    .record-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .record-grid > div, .record-card { padding: 12px; }
    .record-grid strong, .record-card strong { font-size: 17px; }
    .progress-change { align-items: flex-start; }
    .progress-delta { font-size: 22px; }
    .session-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
    .progress-overview-grid,
    .record-grid { grid-template-columns: 1fr; }
}

/* Compact set actions */
.set-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.set-actions form {
    margin: 0;
    display: flex;
}

.set-icon-button {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.duplicate-set-button {
    color: #2563eb;
}

.duplicate-set-button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.duplicate-set-button:hover {
    background: #eff6ff;
}

.delete-set-button {
    color: #b91c1c;
    font: inherit;
    font-size: 26px;
    line-height: 1;
}

.delete-set-button:hover {
    background: #fef2f2;
}

@media (max-width: 700px) {
    .sets-table tr {
        grid-template-columns: repeat(3, minmax(0, 1fr)) 80px;
    }

    .sets-table td.set-actions {
        display: flex;
        grid-column: auto;
        justify-content: flex-end;
        align-items: center;
        align-self: center;
        gap: 2px;
        padding: 0;
    }

    .set-icon-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .duplicate-set-button svg {
        width: 21px;
        height: 21px;
    }
}


/* Compact exercise actions and inline title editing */
.exercise-heading { align-items: center; }
.exercise-title-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.exercise-title-row h2 { margin: 0; min-width: 0; }
.exercise-heading > form { margin: 0; flex: 0 0 auto; }
.exercise-icon-button {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.edit-exercise-button { color: #64748b; }
.edit-exercise-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.edit-exercise-button:hover { color: #334155; background: #f1f5f9; }
.delete-exercise-button {
    color: #94a3b8;
    font: inherit;
    font-size: 28px;
    line-height: 1;
}
.delete-exercise-button:hover { color: #64748b; background: #f1f5f9; }
.exercise-edit-form {
    display: none;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    margin: 10px 0 14px;
}
.exercise-edit-form.is-open { display: grid; }
.exercise-edit-form input { min-width: 0; width: 100%; }

@media (max-width: 520px) {
    .exercise-heading { gap: 6px; }
    .exercise-title-row { gap: 4px; }
    .exercise-title-row h2 { font-size: clamp(22px, 6vw, 28px); }
    .exercise-icon-button { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
    .exercise-edit-form { grid-template-columns: 1fr 1fr; }
    .exercise-edit-form input { grid-column: 1 / -1; }
    .exercise-edit-form .button { width: 100%; }
}

/* Exercise types: bodyweight, timed and cardio sets */
.exercise-edit-form select {
    min-width: 180px;
}

@media (max-width: 700px) {
    .sets-table.type-reps_only thead tr,
    .sets-table.type-reps_only tbody tr,
    .sets-table.type-duration thead tr,
    .sets-table.type-duration tbody tr {
        grid-template-columns: minmax(62px, .7fr) minmax(0, 1.2fr) 80px;
    }

    .sets-table.type-distance_duration thead tr,
    .sets-table.type-distance_duration tbody tr,
    .sets-table.type-weight_reps thead tr,
    .sets-table.type-weight_reps tbody tr {
        grid-template-columns: repeat(3, minmax(0, 1fr)) 80px;
    }

    .exercise-title-row {
        flex-wrap: wrap;
    }

}

@media (max-width: 520px) {
    .exercise-edit-form select {
        grid-column: 1 / -1;
        min-width: 0;
    }

    .set-entry-form label {
        min-width: 0;
    }
}


/* Workout edit: exercise ordering */
.exercise-order-panel { margin-top: 18px; }
.exercise-order-panel h2 { margin: 0 0 4px; }
.exercise-order-list { display: grid; gap: 8px; margin-top: 16px; }
.exercise-order-item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}
.exercise-order-number {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 14px;
    font-weight: 700;
}
.exercise-order-name { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.exercise-order-actions { display: flex; gap: 6px; }
.exercise-order-actions form { margin: 0; }
.order-button {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: white;
    color: #334155;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.order-button:hover:not(:disabled) { background: #f1f5f9; }
.order-button:disabled { opacity: .3; cursor: default; }

@media (max-width: 430px) {
    .exercise-order-item { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; padding: 9px; }
    .exercise-order-number { width: 28px; height: 28px; }
    .order-button { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
}

/* Group identical sets into one compact row */
.grouped-sets-table .set-count-cell {
    width: 150px;
}

.set-count-control {
    display: inline-grid;
    grid-template-columns: 36px minmax(30px, auto) 36px;
    align-items: center;
    justify-content: end;
    gap: 6px;
    white-space: nowrap;
}

.set-count-control form {
    margin: 0;
    display: flex;
}

.set-count-control strong {
    min-width: 28px;
    text-align: center;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.set-count-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #475569;
    font: inherit;
    font-size: 21px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.set-count-button:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

@media (max-width: 700px) {
    .grouped-sets-table.type-weight_reps thead tr,
    .grouped-sets-table.type-weight_reps tbody tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 128px;
    }

    .grouped-sets-table.type-reps_only thead tr,
    .grouped-sets-table.type-reps_only tbody tr,
    .grouped-sets-table.type-duration thead tr,
    .grouped-sets-table.type-duration tbody tr {
        grid-template-columns: minmax(0, 1fr) 128px;
    }

    .grouped-sets-table.type-distance_duration thead tr,
    .grouped-sets-table.type-distance_duration tbody tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 128px;
    }

    .grouped-sets-table .set-count-cell {
        width: auto;
        padding-right: 0;
    }

    .set-count-control {
        grid-template-columns: 34px 28px 34px;
        gap: 4px;
    }

    .set-count-button {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }
}

@media (max-width: 390px) {
    .grouped-sets-table.type-weight_reps thead tr,
    .grouped-sets-table.type-weight_reps tbody tr,
    .grouped-sets-table.type-distance_duration thead tr,
    .grouped-sets-table.type-distance_duration tbody tr {
        grid-template-columns: minmax(0, .9fr) minmax(0, .9fr) 118px;
    }

    .set-count-control {
        grid-template-columns: 32px 24px 32px;
        gap: 3px;
    }

    .set-count-button {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
}

/* Export format chooser */
.export-picker {
    position: relative;
    display: inline-block;
}

.export-picker > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.export-picker > summary::-webkit-details-marker {
    display: none;
}

.export-picker > summary::marker {
    display: none;
    content: "";
}

.export-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 9px);
    right: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
}

.export-menu::before {
    content: "";
    position: absolute;
    top: -5px;
    right: 24px;
    width: 9px;
    height: 9px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    border-top: 1px solid #e2e8f0;
    transform: rotate(45deg);
}

.export-menu-title {
    padding: 7px 9px 8px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.export-option {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    min-height: 54px;
    padding: 8px 10px;
    border-radius: 11px;
    color: #0f172a;
    text-decoration: none;
    transition: background-color .15s ease, transform .15s ease;
}

.export-option:hover,
.export-option:focus-visible {
    background: #f8fafc;
    outline: none;
}

.export-option:active {
    transform: scale(.985);
}

.export-option-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
}

.export-option-icon svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.export-option-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.export-option-copy strong {
    color: #0f172a;
    font-size: 14px;
    line-height: 1.25;
}

.export-option-copy > span {
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
}

@media (max-width: 520px) {
    .export-picker {
        width: 100%;
    }

    .export-picker > summary {
        width: 100%;
        box-sizing: border-box;
        justify-content: center;
    }

    .export-menu {
        left: 0;
        right: auto;
        width: 100%;
        box-sizing: border-box;
        border-radius: 14px;
    }

    .export-menu::before {
        left: 50%;
        right: auto;
        transform: translateX(-50%) rotate(45deg);
    }

    .export-option {
        min-height: 58px;
    }
}

/* Workout templates */
.eyebrow {
    display: inline-block;
    margin-bottom: 7px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.template-list { display: grid; gap: 12px; }
.template-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px 12px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(15,23,42,.04);
}
.template-card-main {
    min-width: 0;
    display: grid;
    gap: 4px;
    padding: 7px 0;
    color: inherit;
    text-decoration: none;
}
.template-card-main strong { font-size: 17px; overflow-wrap: anywhere; }
.template-card-main:hover strong { color: #2563eb; }
.template-card form { margin: 0; }
.template-start-button { min-width: 104px; }
.template-heading .actions form { margin: 0; }
.template-name-panel { padding-top: 16px; padding-bottom: 16px; }
.template-order-actions {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;
}
.template-order-actions form { margin: 0; display: flex; }
.template-order-button {
    width: 27px;
    height: 23px;
    min-width: 27px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.template-order-button:hover:not(:disabled) { background: #e2e8f0; color: #334155; }
.template-order-button:disabled { opacity: .28; cursor: default; }
.template-exercise-card .exercise-title-row {
    grid-template-columns: 27px minmax(0, 1fr) 34px;
    align-items: start;
    width: 100%;
}
.template-exercise-card .template-order-actions {
    grid-column: 1;
}
.template-exercise-card .exercise-title-row h2 {
    grid-column: 2;
    min-width: 0;
}
.template-exercise-card .edit-exercise-button {
    grid-column: 3;
}

@media (max-width: 520px) {
    .nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        gap: 5px 8px;
    }
    .nav a, .nav-button {
        width: 100%;
        min-width: 0;
        min-height: 36px;
        justify-content: center;
        text-align: center;
        padding: 4px 6px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav a:nth-child(2) { max-width: none; }
    .nav form { min-width: 0; }

    .template-card { grid-template-columns: minmax(0, 1fr) 94px; padding: 10px 10px 10px 14px; gap: 8px; }
    .template-start-button { width: 100%; min-width: 0; padding-left: 9px; padding-right: 9px; }
    .template-heading .actions { grid-template-columns: 1fr; }
    .template-heading .actions > * { grid-column: 1 / -1; }
    .template-order-button { width: 26px; height: 22px; min-width: 26px; }
}


/* Date status accents for workout cards */
.workout-card-today {
    border-color: #d4a017;
    background: linear-gradient(135deg, #fffdf3 0%, #fff8dc 100%);
    box-shadow: 0 4px 14px rgba(180, 125, 0, .10);
}
.workout-card-today:hover {
    border-color: #b8860b;
    box-shadow: 0 6px 18px rgba(180, 125, 0, .16);
}
.workout-card-today .workout-card-main strong { color: #7a5600; }
.workout-card-today .workout-card-main .muted { color: #9a6d00; }

.workout-card-past {
    border-color: #86c79a;
    background: linear-gradient(135deg, #fbfffc 0%, #eefaf1 100%);
    box-shadow: 0 4px 14px rgba(22, 101, 52, .07);
}
.workout-card-past:hover {
    border-color: #5da874;
    box-shadow: 0 6px 18px rgba(22, 101, 52, .12);
}
.workout-card-past .workout-card-main strong { color: #14532d; }
.workout-card-past .workout-card-main .muted { color: #4f7f5e; }

/* Compact workout entry, repeat action and optional previous-performance comparison */
.workout-card-main {
    min-width: 0;
    flex: 1 1 auto;
    color: inherit;
    text-decoration: none;
}
.workout-card-main strong,
.workout-card-main .muted {
    display: block;
}
.workout-card-main strong { margin-bottom: 4px; }
.workout-card-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}
.workout-card-actions form { margin: 0; }
.workout-open-link {
    color: #475569;
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}
.workout-open-link:hover { color: #2563eb; }

.add-set-disclosure {
    margin-top: 10px;
}
.add-set-disclosure > summary::-webkit-details-marker,
.previous-result > summary::-webkit-details-marker {
    display: none;
}
.add-set-disclosure > summary,
.previous-result > summary {
    list-style: none;
}
.add-set-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 7px 11px;
    border: 1px dashed #cbd5e1;
    border-radius: 9px;
    color: #475569;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    user-select: none;
}
.add-set-toggle:focus {
    background: transparent;
}
.add-set-toggle:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) {
    .add-set-toggle:hover { border-color: #94a3b8; background: #f8fafc; color: #1e293b; }
}
@media (hover: none), (pointer: coarse) {
    .add-set-toggle:active { border-color: #94a3b8; background: rgba(148,163,184,.10); }
}
.add-set-disclosure[open] .add-set-toggle { margin-bottom: 12px; }
.add-set-disclosure .set-entry-form {
    padding: 12px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.previous-result {
    margin: 8px 0 10px;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}
.previous-result > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 7px 2px;
    color: #64748b;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}
.previous-result > summary:hover { color: #334155; }
.previous-result-date {
    font-weight: 500;
    white-space: nowrap;
}
.previous-result-body {
    display: grid;
    gap: 7px;
    padding: 2px 0 10px;
}
.previous-result-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 7px;
    color: #475569;
    font-size: 14px;
}
.previous-result-row span:not(:last-child)::after {
    content: '×';
    margin-left: 7px;
    color: #94a3b8;
}
.previous-result-row strong {
    color: #1e293b;
    font-size: 14px;
}
.previous-result-link {
    width: fit-content;
    color: #64748b;
    font-size: 13px;
    text-decoration: none;
}
.previous-result-link:hover { color: #2563eb; }

@media (max-width: 700px) {
    .workout-card {
        align-items: stretch;
    }
    .workout-card-actions {
        gap: 8px;
    }
    .repeat-workout-button {
        min-height: 38px;
        padding: 7px 10px;
        font-size: 13px;
    }
    .workout-open-link { display: none; }
    .add-set-toggle {
        width: 100%;
        justify-content: center;
        min-height: 40px;
    }
    .add-set-disclosure .set-entry-form {
        padding: 10px;
    }
}

@media (max-width: 430px) {
    .workout-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
    }
    .workout-card-actions { align-self: center; }
    .previous-result > summary { min-height: 36px; }
}

/* Desktop navigation contrast and workout action toolbar */
.topbar .brand {
    color: #ffffff;
}

.topbar .nav a,
.topbar .nav-button {
    color: #cbd5e1;
}

.topbar .nav a:hover,
.topbar .nav a.active {
    color: #ffffff;
}

.topbar .nav-button:hover {
    color: #fecaca;
}

.workout-page-heading {
    margin-bottom: 14px;
}

.workout-toolbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 28px;
    padding: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, .035);
}

.workout-toolbar-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.workout-toolbar form,
.workout-toolbar .export-picker {
    margin: 0;
}

.workout-toolbar .button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.workout-toolbar-danger {
    flex: 0 0 auto;
    padding-left: 12px;
    border-left: 1px solid #e2e8f0;
}

@media (max-width: 700px) {
    .workout-page-heading {
        margin-bottom: 12px;
    }

    .workout-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
        margin-bottom: 22px;
    }

    .workout-toolbar-main {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .workout-toolbar-main > *,
    .workout-toolbar-main form,
    .workout-toolbar-main .button,
    .workout-toolbar-main .export-picker,
    .workout-toolbar-main .export-picker > summary {
        width: 100%;
        min-width: 0;
    }

    .workout-toolbar-danger {
        padding: 8px 0 0;
        border-left: 0;
        border-top: 1px solid #e2e8f0;
    }

    .workout-toolbar-danger .button {
        width: 100%;
    }
}


/* Exercise title alignment + subtle repeat action */
.exercise-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}

.exercise-title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: start;
    gap: 6px;
    min-width: 0;
}

.exercise-title-row h2 {
    min-width: 0;
    overflow-wrap: anywhere;
}

.exercise-title-row .edit-exercise-button {
    align-self: start;
    margin-top: 1px;
}

.workout-repeat-icon-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.workout-repeat-icon-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.workout-repeat-icon-button:hover,
.workout-repeat-icon-button:focus-visible {
    color: #2563eb;
    border-color: #93c5fd;
    background: #eff6ff;
}

@media (max-width: 700px) {
    .exercise-title-row {
        grid-template-columns: minmax(0, 1fr) 32px;
        gap: 5px;
    }

    .exercise-title-row .exercise-icon-button {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }

    .workout-repeat-icon-button {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
}


/* Workout top metadata row: navigation on the left, date on the right */
.workout-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.workout-meta-row .back-link {
    margin-bottom: 0;
}

.workout-date {
    flex: 0 0 auto;
    color: #64748b;
    font-size: .95rem;
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 700px) {
    .workout-meta-row {
        gap: 12px;
        margin-bottom: 14px;
    }

    .workout-date {
        font-size: .9rem;
    }
}

/* Non-blocking feedback for AJAX operations. */
.ego-toast-host {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 5000;
    display: grid;
    gap: 10px;
    width: min(390px, calc(100vw - 32px));
    pointer-events: none;
}

.ego-toast {
    padding: 12px 14px;
    border-radius: 12px;
    background: #1f2937;
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
    font-size: 14px;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}

.ego-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.ego-toast-error {
    border-left: 4px solid #dc2626;
}

/* Home Screen / PWA standalone mode.
   WebKit can report dvh/svh without the safe-area contribution for installed
   apps using viewport-fit=cover. In standalone mode, 100vh is the reliable
   full-screen fallback (WebKit bug 254868). */
@media (display-mode: standalone) {
    html, body { min-height: 100vh; }
}

/* Workout status controls and tactile interaction polish */
a, button, summary, [role="button"] {
    -webkit-tap-highlight-color: transparent;
}

.button,
.nav-button,
.workout-repeat-icon-button,
.exercise-icon-button,
.template-order-button,
.workout-status-pill,
.workout-status-option,
.export-option {
    transition:
        transform .16s cubic-bezier(.2,.8,.2,1),
        box-shadow .18s ease,
        background-color .18s ease,
        border-color .18s ease,
        color .18s ease,
        opacity .18s ease;
    transform-origin: center;
}

.button:active,
.workout-repeat-icon-button:active,
.exercise-icon-button:active,
.template-order-button:active,
.workout-status-pill:active,
.workout-status-option:active,
.export-option:active {
    transform: translateY(1px) scale(.975);
}

.workout-card {
    position: relative;
    transition:
        transform .18s cubic-bezier(.2,.8,.2,1),
        box-shadow .2s ease,
        border-color .2s ease,
        background-color .2s ease;
    transform-origin: center;
}

.workout-card-main {
    border-radius: 10px;
    outline: none;
    transition: opacity .15s ease;
}

.workout-card-main:active {
    opacity: .82;
}

.workout-card:has(.workout-card-main:active) {
    transform: scale(.992);
}

@media (hover: hover) and (pointer: fine) {
    .button:hover,
    .workout-repeat-icon-button:hover,
    .exercise-icon-button:hover,
    .template-order-button:hover {
        transform: translateY(-1px);
    }
    .workout-card:hover {
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .button,
    .nav-button,
    .workout-repeat-icon-button,
    .exercise-icon-button,
    .template-order-button,
    .workout-status-pill,
    .workout-status-option,
    .export-option,
    .workout-card,
    .workout-card-main {
        transition: none !important;
    }
}

/* Explicit workout states. Today's workout stays gold unless it is skipped. */
.workout-card-completed {
    border-color: #86c79a;
    background: linear-gradient(135deg, #fbfffc 0%, #eefaf1 100%);
    box-shadow: 0 4px 14px rgba(22, 101, 52, .07);
}
.workout-card-completed .workout-card-main strong { color: #14532d; }
.workout-card-completed .workout-card-main .muted { color: #4f7f5e; }

.workout-card-skipped {
    border-color: #e6a0a0;
    background: linear-gradient(135deg, #fffdfd 0%, #fff0f0 100%);
    box-shadow: 0 4px 14px rgba(185, 28, 28, .07);
}
.workout-card-skipped .workout-card-main strong { color: #991b1b; }
.workout-card-skipped .workout-card-main .muted { color: #b45353; }

.workout-card-planned {
    border-color: #dbe2ea;
    background: #fff;
}

@media (hover: hover) and (pointer: fine) {
    .workout-card-completed:hover { border-color: #5da874; box-shadow: 0 9px 24px rgba(22,101,52,.12); }
    .workout-card-skipped:hover { border-color: #cf6f6f; box-shadow: 0 9px 24px rgba(185,28,28,.12); }
    .workout-card-today:hover { box-shadow: 0 9px 24px rgba(180,125,0,.15); }
}

.workout-status-picker {
    position: relative;
    flex: 0 0 auto;
}

.workout-status-picker > summary::-webkit-details-marker { display: none; }
.workout-status-picker > summary { list-style: none; }

.workout-status-pill {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid #d7dee8;
    border-radius: 999px;
    background: rgba(255,255,255,.76);
    color: #475569;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    backdrop-filter: blur(5px);
}

.workout-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148,163,184,.12);
    flex: 0 0 auto;
}

.status-completed .workout-status-dot,
.workout-status-dot.status-completed {
    background: #22a35a;
    box-shadow: 0 0 0 3px rgba(34,163,90,.13);
}
.status-skipped .workout-status-dot,
.workout-status-dot.status-skipped {
    background: #dc4c4c;
    box-shadow: 0 0 0 3px rgba(220,76,76,.12);
}
.status-planned .workout-status-dot,
.workout-status-dot.status-planned {
    background: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148,163,184,.12);
}

.workout-status-menu {
    position: absolute;
    z-index: 80;
    right: 0;
    top: calc(100% + 8px);
    width: 210px;
    padding: 8px;
    border: 1px solid #dde4ed;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(15,23,42,.16);
}

.workout-status-menu-title {
    padding: 5px 8px 8px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.workout-status-menu form { margin: 0; }

.workout-status-option {
    width: 100%;
    min-height: 42px;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #273449;
    text-align: left;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
}

.workout-status-option:hover,
.workout-status-option:focus-visible {
    background: #f4f7fb;
    outline: none;
}

.workout-status-option.is-current { background: #f8fafc; }
.workout-status-check { justify-self: end; color: #2563eb; font-weight: 800; }

@media (max-width: 700px) {
    .workout-card-actions { gap: 8px; }
    .workout-status-pill {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        padding: 0;
        justify-content: center;
        border-radius: 10px;
        background: rgba(255,255,255,.82);
    }
    .workout-status-label { display: none; }
    .workout-status-dot { width: 10px; height: 10px; }
    .workout-status-menu {
        position: fixed;
        left: 14px;
        right: 14px;
        top: auto;
        bottom: max(14px, env(safe-area-inset-bottom));
        width: auto;
        border-radius: 18px;
        padding: 10px;
        box-shadow: 0 20px 55px rgba(15,23,42,.24);
    }
    .workout-status-option { min-height: 50px; font-size: 16px; }
}

.nav a, .nav-button, .back-link, .workout-open-link {
    transition: color .16s ease, opacity .16s ease, transform .16s cubic-bezier(.2,.8,.2,1);
    -webkit-tap-highlight-color: transparent;
}
.nav a:active, .nav-button:active, .back-link:active, .workout-open-link:active {
    transform: translateY(1px) scale(.98);
    opacity: .82;
}

.ajax-updated {
    animation: ego-soft-update .24s cubic-bezier(.2,.8,.2,1);
}
@keyframes ego-soft-update {
    0% { opacity: .72; transform: scale(.994); }
    100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .ajax-updated { animation: none; }
}

/* Status popover stacking + reliable pressed feedback for touch devices */
.workout-card:has(.workout-status-picker[open]) {
    z-index: 120;
}

.workout-status-picker[open] {
    z-index: 130;
}

.workout-status-picker[open] .workout-status-menu {
    z-index: 140;
}

/* Safari/PWA can make :active too brief to feel tactile. JS keeps this class
   for a short minimum interval so the press feedback is actually visible. */
.button.is-pressed,
.nav-button.is-pressed,
.workout-repeat-icon-button.is-pressed,
.exercise-icon-button.is-pressed,
.template-order-button.is-pressed,
.workout-status-pill.is-pressed,
.workout-status-option.is-pressed,
.export-option.is-pressed,
.workout-open-link.is-pressed,
.back-link.is-pressed {
    transform: translateY(1px) scale(.975);
    opacity: .84;
}

.workout-card.is-pressed {
    transform: scale(.988);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.workout-card.is-pressed .workout-card-main {
    opacity: .82;
}

@media (hover: none) and (pointer: coarse) {
    .button,
    .nav-button,
    .workout-repeat-icon-button,
    .exercise-icon-button,
    .template-order-button,
    .workout-status-pill,
    .workout-status-option,
    .export-option,
    .workout-open-link,
    .back-link,
    .workout-card {
        transition-duration: .12s;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Keep state feedback visible even when motion is disabled. */
    .button.is-pressed,
    .nav-button.is-pressed,
    .workout-repeat-icon-button.is-pressed,
    .exercise-icon-button.is-pressed,
    .template-order-button.is-pressed,
    .workout-status-pill.is-pressed,
    .workout-status-option.is-pressed,
    .export-option.is-pressed,
    .workout-open-link.is-pressed,
    .back-link.is-pressed {
        opacity: .72;
        transform: none;
    }
    .workout-card.is-pressed {
        transform: none;
        filter: brightness(.97);
    }
}


/* Per-control loading feedback --------------------------------------------------
   Every interactive control gets its own small real DOM spinner. The control
   stays readable and keeps its size; only repeated taps on that control are
   blocked while its action is pending. */
.ego-action-loading {
    cursor: wait !important;
    pointer-events: none !important;
}

.ego-action-loader {
    position: absolute;
    z-index: 30;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    box-sizing: border-box;
    border: 2px solid rgba(100, 116, 139, .28);
    border-top-color: #2563eb;
    border-radius: 50%;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .86), 0 2px 6px rgba(15, 23, 42, .18);
    animation: ego-action-loader-spin .68s linear infinite;
    pointer-events: none;
}

@keyframes ego-action-loader-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .ego-action-loader {
        animation-duration: 1.15s;
    }
}

.ego-toast-success {
    border-left: 4px solid #16a34a;
}

.flash-toast-source {
    display: none !important;
}

/* Exercise dictionary autocomplete */
.exercise-autocomplete-field {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

.exercise-autocomplete-field > input {
    width: 100%;
}

.exercise-edit-form .exercise-autocomplete-field {
    flex: 1 1 240px;
}

.exercise-suggestions {
    position: absolute;
    z-index: 40;
    top: auto;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: min(360px, 90vw);
    /* About 3-4 suggestions at once; the rest stay available by scrolling. */
    max-height: 192px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
}

.exercise-suggestions.is-below {
    top: calc(100% + 6px);
    bottom: auto;
}

.exercise-suggestion {
    width: 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.exercise-suggestion:hover,
.exercise-suggestion:focus-visible {
    background: #f1f5f9;
    outline: none;
}

.exercise-suggestion small {
    color: #64748b;
    font-weight: 400;
    text-align: right;
}

.progress-favorites-panel {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.progress-favorite-form {
    align-items: end;
}

.progress-favorite-card {
    display: block;
    padding: 0;
}

.progress-card-link {
    display: block;
    padding: 18px;
    color: inherit;
    text-decoration: none;
}

.progress-favorite-remove {
    display: flex;
    justify-content: flex-end;
    padding: 0 18px 18px;
}

.progress-favorite-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}
.progress-favorite-form > label,
.progress-favorite-form > .exercise-autocomplete {
    width: 100%;
    min-width: 0;
}
.progress-favorite-form > .button {
    width: 100%;
}
/* Workout editor: keep form controls inside the card on narrow screens. */
.workout-editor-form > label,
.workout-editor-form input,
.workout-editor-form textarea {
    min-width: 0;
    max-width: 100%;
}

/* iOS Safari paints the native date control wider than its grid cell when it
   is forced to width: 100%. Let the grid stretch it instead: this preserves
   the native date picker while making its right edge match the other fields. */
.workout-editor-form input[type="date"] {
    display: block;
    width: auto;
    inline-size: auto;
    min-width: 0;
    min-inline-size: 0;
    max-width: 100%;
    max-inline-size: 100%;
    justify-self: stretch;
}

/* Adaptive application shell: desktop sidebar + mobile bottom navigation */
.app-nav-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.app-nav-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-shell-page {
    padding-left: 224px;
    padding-bottom: 28px;
}
.app-shell-page > main.container {
    width: min(960px, calc(100% - 64px));
    margin-top: 32px;
    margin-bottom: 48px;
}
.app-shell-page > main.container.narrow {
    width: min(680px, calc(100% - 64px));
}
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 900;
    width: 224px;
    display: flex;
    flex-direction: column;
    padding: 26px 14px 18px;
    color: #cbd5e1;
    background: #111827;
    border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-brand {
    padding: 0 14px 24px;
    color: #fff;
    font-size: 20px;
    font-weight: 850;
    letter-spacing: .09em;
    text-decoration: none;
}
.sidebar-nav {
    display: grid;
    gap: 5px;
}
.sidebar-nav a {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 13px;
    border: 0;
    border-radius: 11px;
    color: #cbd5e1;
    background: transparent;
    font: inherit;
    font-weight: 650;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.sidebar-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
}
.sidebar-nav a.active {
    color: #fff;
    background: #2563eb;
}
.sidebar-account {
    position: relative;
    margin: auto 0 0;
}
.sidebar-account > summary::-webkit-details-marker {
    display: none;
}
.sidebar-account > summary {
    list-style: none;
}
.sidebar-account-trigger {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 13px;
    color: #e2e8f0;
    background: rgba(255,255,255,.035);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.sidebar-account-trigger:hover,
.sidebar-account[open] .sidebar-account-trigger {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.13);
}
.sidebar-account.is-active:not([open]) .sidebar-account-trigger {
    background: rgba(37,99,235,.18);
    border-color: rgba(96,165,250,.24);
}
.sidebar-account-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: #dbeafe;
    background: #1f2937;
}
.sidebar-account-avatar svg,
.sidebar-account-chevron svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sidebar-account-copy {
    min-width: 0;
    display: block;
}
.sidebar-account-copy strong,
.sidebar-account-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-account-copy strong {
    color: inherit;
    font-size: 14px;
    font-weight: 750;
}
.sidebar-account-copy small {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 600;
}
.sidebar-account-chevron {
    display: grid;
    place-items: center;
    color: #94a3b8;
    transition: transform .16s ease;
}
.sidebar-account[open] .sidebar-account-chevron {
    transform: rotate(180deg);
}
.sidebar-account-menu {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    display: grid;
    gap: 3px;
    padding: 6px;
    border: 1px solid #334155;
    border-radius: 13px;
    background: #172033;
    box-shadow: 0 18px 45px rgba(0,0,0,.34);
}
.sidebar-account-menu a,
.sidebar-account-menu button {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    color: #cbd5e1;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.sidebar-account-menu a:hover,
.sidebar-account-menu button:hover,
.sidebar-account-menu a.active {
    color: #fff;
    background: rgba(255,255,255,.08);
}
.sidebar-account-menu form {
    margin: 3px 0 0;
    padding-top: 3px;
    border-top: 1px solid #334155;
}
.sidebar-account-menu .sidebar-account-logout:hover {
    color: #fecaca;
    background: rgba(185,28,28,.18);
}

.profile-heading-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.profile-settings-shortcut {
    display: none;
    width: 46px;
    min-width: 46px;
    padding: 0;
}
.profile-settings-shortcut svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mobile-app-topbar,
.mobile-bottom-nav {
    display: none;
}

@media (min-width: 1400px) {
    .app-shell-page > main.container {
        width: min(1000px, calc(100% - 96px));
    }
}

@media (max-width: 800px) {
    body.app-shell-page {
        min-height: 100vh;
        min-height: 100dvh;
        padding-left: 0;
        padding-bottom: 0;
    }
    .app-sidebar {
        display: none;
    }
    .app-shell-page > main.container,
    .app-shell-page > main.container.narrow {
        width: calc(100% - 28px);
        margin-top: 22px;
        margin-bottom: 0;
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }
    .profile-heading-actions {
        width: 100%;
    }
    .profile-heading-actions > .button:first-child {
        flex: 1 1 auto;
    }
    .profile-settings-shortcut {
        display: inline-flex;
        flex: 0 0 46px;
    }
    .mobile-app-topbar {
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: max(10px, env(safe-area-inset-top)) 16px 10px;
        color: #fff;
        background: #111827;
    }
    .mobile-app-brand {
        color: #fff;
        font-size: 17px;
        font-weight: 850;
        letter-spacing: .08em;
        text-decoration: none;
    }
    .mobile-app-topbar form {
        margin: 0;
    }
    .mobile-logout {
        border: 0;
        padding: 8px 0 8px 12px;
        color: #cbd5e1;
        background: transparent;
        font: inherit;
        font-weight: 650;
    }
    .mobile-bottom-nav {
        position: fixed;
        z-index: 1200;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        min-height: calc(72px + env(safe-area-inset-bottom));
        padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
        background: rgba(255,255,255,.96);
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -8px 28px rgba(15,23,42,.09);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
    }
    .mobile-bottom-nav a {
        min-width: 0;
        min-height: 58px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 5px 2px;
        border-radius: 10px;
        color: #64748b;
        font-size: 11px;
        font-weight: 650;
        line-height: 1.1;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    .mobile-bottom-nav .app-nav-icon {
        width: 24px;
        height: 24px;
        flex-basis: 24px;
    }
    .mobile-bottom-nav a.active {
        color: #2563eb;
    }
    .mobile-bottom-nav a:active {
        background: #eff6ff;
    }
}


/* Popovers that open from workout cards must stay above the fixed tab bar. */
@media (max-width: 800px) {
    .workout-card:has(.workout-status-picker[open]) { z-index: 1310; }
    .workout-status-picker[open] { z-index: 1320; }
    .workout-status-picker[open] .workout-status-menu { z-index: 1330; }

    .workout-status-menu {
        bottom: calc(82px + env(safe-area-inset-bottom));
        max-height: min(320px, calc(100dvh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* Keep short installed-app pages as tall as the real iOS standalone viewport.
   This rule intentionally comes after body.app-shell-page's 100dvh rule: on
   affected WebKit versions 100dvh is shorter by the safe-area offset. */
@media (display-mode: standalone) and (max-width: 800px) {
    body.app-shell-page {
        min-height: 100vh;
    }

    .workout-status-menu {
        max-height: min(320px, calc(100vh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    }
}

/* Template rename form: keep the name field full-width on compact screens. */
@media (max-width: 700px) {
    .template-name-panel .inline-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .template-name-panel .inline-form > .grow,
    .template-name-panel .inline-form > .button,
    .template-name-panel .inline-form > .full-width {
        grid-column: 1;
        width: 100%;
        min-width: 0;
    }
}

/* History-based workout generation ------------------------------------------ */
.generation-form {
    margin: 0;
}

.generation-summary {
    margin: 0 0 22px;
    padding: 20px;
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.generation-summary-heading h2 {
    margin: 4px 0 6px;
}

.generation-summary-heading p {
    margin: 0;
}

.generation-summary-heading a {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.generation-summary-heading a:hover {
    text-decoration: underline;
}

.generation-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.generation-summary-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.generation-exercise {
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
}

.generation-exercise-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.generation-exercise-heading > strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
}

.generation-action {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.generation-action-increase_weight,
.generation-action-increase_reps,
.generation-action-increase_duration {
    background: #dcfce7;
    color: #166534;
}

.generation-action-no_data {
    background: #fef3c7;
    color: #92400e;
}

.generation-values {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.generation-values > div {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
}

.generation-values span:not(.generation-arrow) {
    display: block;
    margin-bottom: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.generation-values b {
    display: block;
    overflow-wrap: anywhere;
    color: #0f172a;
    font-size: 14px;
}

.generation-arrow {
    color: #94a3b8;
    font-weight: 800;
}

.generation-exercise > p {
    margin: 10px 0 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
}

.generation-disclaimer {
    margin: 14px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

@media (max-width: 700px) {
    .workout-toolbar-main .generation-form {
        grid-column: 1 / -1;
    }

    .generation-summary {
        padding: 16px;
        margin-bottom: 18px;
    }

    .generation-values {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .generation-arrow {
        justify-self: center;
        transform: rotate(90deg);
    }
}

/* Adaptive workout generator ------------------------------------------------ */
.smart-generator-panel {
    margin-top: 20px;
    padding: 20px;
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.smart-generator-heading h2 {
    margin: 6px 0 8px;
}

.smart-generator-heading p {
    margin: 0;
}

.generator-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.generator-profile-grid > div {
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
}

.generator-profile-grid span {
    display: block;
    margin-bottom: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.generator-profile-grid strong {
    display: block;
    overflow-wrap: anywhere;
    color: #0f172a;
    font-size: 14px;
}

.generator-profile-note {
    margin: 12px 0 0;
    color: #64748b;
    font-size: 13px;
}

.generator-profile-note a {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.smart-generator-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
    margin-top: 16px;
}

.smart-generator-form label {
    min-width: 0;
}

.smart-generator-form select {
    width: 100%;
}

.generator-submit {
    min-height: 46px;
}

.adaptive-generation-context {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #eff6ff;
    color: #334155;
    font-size: 13px;
    line-height: 1.45;
}

.adaptive-exercise-title {
    min-width: 0;
}

.adaptive-exercise-title > strong {
    display: block;
    overflow-wrap: anywhere;
}

.muscle-label {
    display: inline-block;
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.generation-badges {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.generation-new-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.generation-values small {
    display: block;
    margin-top: 3px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
}

.workout-difficulty-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.difficulty-copy h2 {
    margin: 0 0 5px;
    font-size: 1.1rem;
}

.difficulty-copy p {
    margin: 0;
    max-width: 620px;
    font-size: 13px;
    line-height: 1.45;
}

.difficulty-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.difficulty-options form {
    margin: 0;
}

.difficulty-button {
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.difficulty-button:hover,
.difficulty-button:active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.difficulty-button.is-selected {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1d4ed8;
}

@media (max-width: 700px) {
    .smart-generator-panel {
        padding: 16px;
    }

    .generator-profile-grid,
    .smart-generator-form,
    .workout-difficulty-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .generator-submit {
        width: 100%;
    }

    .generation-badges {
        flex-wrap: wrap;
    }

    .difficulty-options {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: stretch;
    }

    .difficulty-button {
        width: 100%;
        padding-inline: 8px;
    }
}

/* Per-set effort (RIR) and warm-up tracking */
.generation-action-decrease_weight {
    background: #fee2e2;
    color: #991b1b;
}

.set-warmup-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.2;
    vertical-align: middle;
    white-space: nowrap;
}

.set-effort-disclosure {
    margin: 10px 0 14px;
}

.set-effort-disclosure > summary::-webkit-details-marker {
    display: none;
}

.set-effort-disclosure > summary {
    list-style: none;
}

.set-effort-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.set-effort-toggle-icon {
    position: relative;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: 6px;
    background: #eff6ff;
    color: #2563eb;
}

.set-effort-toggle-icon::before,
.set-effort-toggle-icon::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform: translate(-50%, -50%);
    transform-origin: center;
    transition: opacity .14s ease, transform .14s ease;
}

.set-effort-toggle-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.set-effort-disclosure[open] .set-effort-toggle-icon::after {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scaleX(.2);
}

.set-effort-toggle:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.set-effort-toggle-hint {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
}

.set-effort-section {
    margin: 8px 0 0;
    padding: 12px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #f8fafc;
}

.set-effort-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.set-effort-heading strong {
    color: #0f172a;
    font-size: 14px;
}

.set-effort-heading span {
    color: #64748b;
    font-size: 11px;
    line-height: 1.35;
    text-align: right;
}

.set-effort-list {
    display: grid;
    gap: 7px;
}

.set-effort-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
}

.set-effort-set-info {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.set-effort-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 7px;
    border-radius: 8px;
    background: #eef2f7;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.set-effort-set-info strong {
    min-width: 0;
    color: #0f172a;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.set-effort-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.set-warmup-toggle,
.rir-button,
.rir-clear-button {
    min-height: 34px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.set-warmup-toggle {
    padding: 6px 9px;
    border-radius: 999px;
}

.set-warmup-toggle.is-selected {
    border-color: #64748b;
    background: #e2e8f0;
    color: #0f172a;
}

.rir-scale {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rir-scale-label {
    margin-right: 2px;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .02em;
}

.rir-button,
.rir-clear-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    min-width: 34px;
    padding: 0 4px;
    border-radius: 9px;
    font-variant-numeric: tabular-nums;
}

.rir-button:hover,
.rir-button:active,
.rir-clear-button:hover,
.rir-clear-button:active,
.set-warmup-toggle:hover,
.set-warmup-toggle:active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.rir-button.is-selected {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1d4ed8;
}

.rir-clear-button {
    width: 30px;
    min-width: 30px;
    color: #94a3b8;
}

.set-entry-warmup .checkbox-control {
    display: flex;
    align-items: center;
    min-height: 42px;
    gap: 7px;
    font-weight: 600;
}

.set-entry-warmup input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

@media (max-width: 700px) {
    .set-effort-toggle {
        width: 100%;
        justify-content: flex-start;
        box-sizing: border-box;
    }

    .set-effort-toggle-hint {
        margin-left: auto;
    }

    .set-effort-section {
        margin-inline: 0;
        padding: 10px;
    }

    .set-effort-heading {
        display: block;
    }

    .set-effort-heading span {
        display: block;
        margin-top: 3px;
        text-align: left;
    }

    .set-effort-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 7px;
    }

    .set-effort-controls {
        justify-content: space-between;
    }

    .rir-scale {
        flex-wrap: nowrap;
    }
}

@media (max-width: 390px) {
    .set-effort-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .set-warmup-toggle {
        align-self: flex-start;
    }

    .rir-scale {
        width: 100%;
        justify-content: space-between;
    }

    .rir-scale-label {
        margin-right: 0;
    }

    .rir-button {
        width: 36px;
        min-width: 36px;
    }
}

/* Profile settings ---------------------------------------------------------- */
.settings-page {
    max-width: 760px;
}

.settings-heading {
    margin-bottom: 20px;
}

.settings-section-heading h2 {
    margin-bottom: 6px;
}

.settings-section-heading p {
    margin: 0;
    line-height: 1.5;
}

.theme-settings-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.theme-choice {
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid #d7dee8;
    border-radius: 14px;
    background: #fff;
    color: #172033;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease, background-color .16s ease;
}

.theme-choice:hover,
.theme-choice:focus-visible {
    border-color: #93c5fd;
    box-shadow: 0 5px 18px rgba(37,99,235,.08);
    outline: none;
}

.theme-choice:active {
    transform: scale(.99);
}

.theme-choice.is-selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}

.theme-choice-copy {
    min-width: 0;
}

.theme-choice-copy strong,
.theme-choice-copy small {
    display: block;
}

.theme-choice-copy strong {
    margin-bottom: 4px;
    font-size: 15px;
}

.theme-choice-copy small {
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
}

.theme-selected-mark {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 900;
}

.theme-preview {
    height: 68px;
    display: grid;
    grid-template-columns: 25px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(15,23,42,.08);
}

.theme-preview-sidebar {
    background: #111827;
}

.theme-preview-main {
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 10px 8px;
}

.theme-preview-line {
    width: 58%;
    height: 5px;
    border-radius: 999px;
}

.theme-preview-card {
    width: 100%;
    height: 15px;
    border-radius: 5px;
}

.theme-preview-card.short {
    width: 72%;
}

.theme-preview-light .theme-preview-main {
    background: #f5f7fb;
}

.theme-preview-light .theme-preview-line {
    background: #64748b;
}

.theme-preview-light .theme-preview-card {
    background: #fff;
    border: 1px solid #e2e8f0;
}

.theme-preview-dark .theme-preview-main {
    background: #0b1120;
}

.theme-preview-dark .theme-preview-line {
    background: #94a3b8;
}

.theme-preview-dark .theme-preview-card {
    background: #172033;
    border: 1px solid #334155;
}

.settings-coming-soon {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    color: #64748b;
    font-size: 13px;
    font-weight: 650;
}

@media (max-width: 700px) {
    .theme-settings-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .theme-choice {
        grid-template-columns: 88px minmax(0, 1fr) auto;
        gap: 11px;
        padding: 12px;
    }

    .theme-preview {
        height: 62px;
    }
}

@media (max-width: 390px) {
    .mobile-bottom-nav a {
        font-size: 11px;
        letter-spacing: -.01em;
    }

    .theme-choice {
        grid-template-columns: 76px minmax(0, 1fr) 24px;
    }
}

/* Light theme: native controls and desktop navigation ----------------------
   Explicit color-scheme matters when the OS itself uses dark mode: Safari
   can otherwise render password bullets as white inside a light input. */
html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
    color: #172033;
}

html[data-theme="light"] input[type="password"] {
    color: #172033;
    -webkit-text-fill-color: #172033;
    caret-color: #172033;
}

@media (min-width: 801px) {
    html[data-theme="light"] .app-sidebar {
        color: #475569;
        background: #ffffff;
        border-right-color: #e2e8f0;
        box-shadow: 4px 0 22px rgba(15, 23, 42, .035);
    }

    html[data-theme="light"] .sidebar-brand {
        color: #172033;
    }

    html[data-theme="light"] .sidebar-nav a {
        color: #475569;
    }

    html[data-theme="light"] .sidebar-nav a:hover {
        color: #0f172a;
        background: #f1f5f9;
    }

    html[data-theme="light"] .sidebar-nav a.active {
        color: #1d4ed8;
        background: #eff6ff;
    }

    html[data-theme="light"] .sidebar-account-trigger {
        color: #172033;
        background: #f8fafc;
        border-color: #e2e8f0;
    }

    html[data-theme="light"] .sidebar-account-trigger:hover,
    html[data-theme="light"] .sidebar-account[open] .sidebar-account-trigger {
        color: #0f172a;
        background: #f1f5f9;
        border-color: #cbd5e1;
    }

    html[data-theme="light"] .sidebar-account.is-active:not([open]) .sidebar-account-trigger {
        color: #1d4ed8;
        background: #eff6ff;
        border-color: #bfdbfe;
    }

    html[data-theme="light"] .sidebar-account-avatar {
        color: #2563eb;
        background: #dbeafe;
    }

    html[data-theme="light"] .sidebar-account-copy small,
    html[data-theme="light"] .sidebar-account-chevron {
        color: #64748b;
    }

    html[data-theme="light"] .sidebar-account-menu {
        background: #ffffff;
        border-color: #e2e8f0;
        box-shadow: 0 18px 45px rgba(15, 23, 42, .14);
    }

    html[data-theme="light"] .sidebar-account-menu a,
    html[data-theme="light"] .sidebar-account-menu button {
        color: #334155;
    }

    html[data-theme="light"] .sidebar-account-menu a:hover,
    html[data-theme="light"] .sidebar-account-menu button:hover {
        color: #0f172a;
        background: #f1f5f9;
    }

    html[data-theme="light"] .sidebar-account-menu a.active {
        color: #1d4ed8;
        background: #eff6ff;
    }

    html[data-theme="light"] .sidebar-account-menu form {
        border-top-color: #e2e8f0;
    }

    html[data-theme="light"] .sidebar-account-menu .sidebar-account-logout:hover {
        color: #b91c1c;
        background: #fef2f2;
    }
}

/* Account theme: dark -------------------------------------------------------
   The theme is server-rendered before app.css loads, so installed PWA pages
   and normal browser pages switch without a light-theme flash. */
html[data-theme="dark"] {
    color-scheme: dark;
    color: #e5e7eb;
    background: #0b1120;
}

html[data-theme="dark"] body,
html[data-theme="dark"] body.app-shell-page {
    color: #e5e7eb;
    background: #0b1120;
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] .back-link,
html[data-theme="dark"] .workout-date,
html[data-theme="dark"] .previous-result > summary,
html[data-theme="dark"] .previous-result-link,
html[data-theme="dark"] .record-card > span,
html[data-theme="dark"] .record-card small,
html[data-theme="dark"] .record-grid > div > span,
html[data-theme="dark"] .progress-card small,
html[data-theme="dark"] .progress-session-head .muted,
html[data-theme="dark"] .session-metrics > div > span,
html[data-theme="dark"] .generator-profile-grid span,
html[data-theme="dark"] .generator-profile-note,
html[data-theme="dark"] .generation-values span:not(.generation-arrow),
html[data-theme="dark"] .generation-disclaimer,
html[data-theme="dark"] .generation-exercise > p,
html[data-theme="dark"] .muscle-label,
html[data-theme="dark"] .set-effort-heading span,
html[data-theme="dark"] .rir-scale-label,
html[data-theme="dark"] .theme-choice-copy small,
html[data-theme="dark"] .settings-coming-soon {
    color: #94a3b8;
}

html[data-theme="dark"] :is(
    .panel,
    .exercise-card,
    .workout-card,
    .empty-state,
    .stat-card,
    .progress-card,
    .progress-session,
    .template-card,
    .workout-toolbar,
    .export-menu,
    .exercise-suggestions,
    .generation-exercise,
    .generator-profile-grid > div,
    .set-effort-row,
    .workout-status-menu,
    .theme-choice
) {
    background: #111827;
    border-color: #273449;
    color: #e5e7eb;
    box-shadow: 0 4px 18px rgba(0,0,0,.22);
}

html[data-theme="dark"] :is(
    .panel.subtle,
    .record-grid > div,
    .record-card,
    .session-metrics > div,
    .exercise-order-item,
    .generation-values > div,
    .set-effort-section,
    .add-set-disclosure .set-entry-form
) {
    background: #0f172a;
    border-color: #273449;
    color: #dbe4ef;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    color: #e5e7eb;
    background: #0f172a;
    border-color: #475569;
}

html[data-theme="dark"] input[type="password"] {
    -webkit-text-fill-color: #e5e7eb;
    caret-color: #e5e7eb;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #64748b;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
    border-color: #60a5fa;
    outline-color: rgba(37,99,235,.32);
}

html[data-theme="dark"] .button.secondary {
    color: #e5e7eb;
    background: #172033;
    border-color: #475569;
}

html[data-theme="dark"] .button.secondary:hover {
    background: #1f2a3d;
}

html[data-theme="dark"] table :is(th, td) {
    border-bottom-color: #273449;
}

html[data-theme="dark"] th {
    color: #94a3b8;
}

html[data-theme="dark"] .profile-details > div > span,
html[data-theme="dark"] .stat-card > span {
    color: #94a3b8;
}

html[data-theme="dark"] :is(
    .previous-result-row,
    .previous-result-row strong,
    .generation-values b,
    .generator-profile-grid strong,
    .set-effort-heading strong,
    .set-effort-set-info strong,
    .session-metrics strong,
    .workout-status-option,
    .exercise-order-name
) {
    color: #e5e7eb;
}

html[data-theme="dark"] .exercise-order-number,
html[data-theme="dark"] .set-effort-number,
html[data-theme="dark"] .export-option-icon,
html[data-theme="dark"] .set-warmup-badge {
    color: #cbd5e1;
    background: #1f2937;
}

html[data-theme="dark"] :is(
    .order-button,
    .template-order-button,
    .set-count-button,
    .workout-repeat-icon-button,
    .set-effort-toggle,
    .difficulty-button,
    .set-warmup-toggle,
    .rir-button,
    .rir-clear-button
) {
    color: #cbd5e1;
    background: #172033;
    border-color: #475569;
}

html[data-theme="dark"] :is(
    .order-button:hover:not(:disabled),
    .template-order-button:hover:not(:disabled),
    .set-count-button:hover,
    .set-effort-toggle:hover,
    .set-warmup-toggle:hover,
    .rir-button:hover,
    .rir-clear-button:hover,
    .workout-status-option:hover,
    .workout-status-option:focus-visible,
    .exercise-suggestion:hover,
    .exercise-suggestion:focus-visible
) {
    background: #1e293b;
}

html[data-theme="dark"] .rir-button.is-selected,
html[data-theme="dark"] .difficulty-button.is-selected,
html[data-theme="dark"] .theme-selected-mark {
    color: #bfdbfe;
    background: #1e3a5f;
    border-color: #60a5fa;
}

html[data-theme="dark"] .set-warmup-toggle.is-selected {
    color: #f1f5f9;
    background: #334155;
    border-color: #64748b;
}

html[data-theme="dark"] .workout-card-planned {
    background: #111827;
    border-color: #334155;
}

html[data-theme="dark"] .workout-card-completed {
    border-color: #28633d;
    background: linear-gradient(135deg, #0f1c16 0%, #10251a 100%);
}

html[data-theme="dark"] .workout-card-completed .workout-card-main strong {
    color: #86efac;
}

html[data-theme="dark"] .workout-card-completed .workout-card-main .muted {
    color: #86b596;
}

html[data-theme="dark"] .workout-card-skipped {
    border-color: #7f3333;
    background: linear-gradient(135deg, #211313 0%, #2d1515 100%);
}

html[data-theme="dark"] .workout-card-skipped .workout-card-main strong {
    color: #fca5a5;
}

html[data-theme="dark"] .workout-card-skipped .workout-card-main .muted {
    color: #d58b8b;
}

html[data-theme="dark"] .workout-status-pill {
    color: #cbd5e1;
    background: rgba(17,24,39,.88);
    border-color: #475569;
}

html[data-theme="dark"] .workout-status-option.is-current {
    background: #1e293b;
}

html[data-theme="dark"] .smart-generator-panel,
html[data-theme="dark"] .generation-summary {
    border-color: #274b78;
    background: linear-gradient(180deg, #101c30 0%, #111827 100%);
}

html[data-theme="dark"] .adaptive-generation-context {
    color: #cbd5e1;
    background: #172a46;
}

html[data-theme="dark"] .generation-kicker {
    color: #bfdbfe;
    background: #1e3a5f;
}

html[data-theme="dark"] .generation-action {
    color: #cbd5e1;
    background: #1f2937;
}

html[data-theme="dark"] .generation-action-increase_weight,
html[data-theme="dark"] .generation-action-increase_reps,
html[data-theme="dark"] .generation-action-increase_duration {
    color: #86efac;
    background: #143322;
}

html[data-theme="dark"] .generation-action-decrease_weight {
    color: #fca5a5;
    background: #3b1b1b;
}

html[data-theme="dark"] .generation-action-no_data {
    color: #fde68a;
    background: #3a2e12;
}

html[data-theme="dark"] .generation-new-badge {
    color: #ddd6fe;
    background: #312e58;
}

html[data-theme="dark"] .alert.success {
    color: #bbf7d0;
    background: #102d1d;
    border-color: #1f6a3a;
}

html[data-theme="dark"] .alert.error {
    color: #fecaca;
    background: #351717;
    border-color: #7f1d1d;
}

html[data-theme="dark"] .field-error,
html[data-theme="dark"] .link-danger {
    color: #fca5a5;
}

html[data-theme="dark"] .mobile-bottom-nav {
    background: rgba(15,23,42,.96);
    border-top-color: #334155;
    box-shadow: 0 -8px 28px rgba(0,0,0,.3);
}

html[data-theme="dark"] .mobile-bottom-nav a {
    color: #94a3b8;
}

html[data-theme="dark"] .mobile-bottom-nav a.active {
    color: #60a5fa;
}

html[data-theme="dark"] .mobile-bottom-nav a:active {
    background: #1e293b;
}

html[data-theme="dark"] .ego-action-loader {
    border-color: rgba(148,163,184,.35);
    border-top-color: #60a5fa;
    background: #111827;
    box-shadow: 0 0 0 2px rgba(17,24,39,.9), 0 2px 6px rgba(0,0,0,.35);
}

html[data-theme="dark"] .exercise-suggestion small {
    color: #94a3b8;
}

html[data-theme="dark"] .settings-coming-soon {
    border-color: #475569;
    background: #0f172a;
}

html[data-theme="dark"] .theme-choice:hover,
html[data-theme="dark"] .theme-choice:focus-visible {
    border-color: #60a5fa;
    box-shadow: 0 5px 18px rgba(0,0,0,.24);
}

html[data-theme="dark"] .theme-choice.is-selected {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96,165,250,.14);
}


/* Dark-theme polish for compact workout controls and table separators. */
html[data-theme="dark"] .sets-table tr {
    border-top-color: #273449;
}

html[data-theme="dark"] .previous-result {
    border-top-color: #273449;
    border-bottom-color: #273449;
}

html[data-theme="dark"] .measurements-table tr {
    background: #0f172a;
    border-color: #273449;
}

html[data-theme="dark"] .measurements-table td {
    border-bottom-color: #273449;
}

html[data-theme="dark"] .add-set-toggle {
    color: #cbd5e1;
    background: transparent;
    border-color: #475569;
}

html[data-theme="dark"] .add-set-toggle:focus {
    background: transparent;
}

html[data-theme="dark"] .set-effort-toggle-icon {
    color: #60a5fa;
    background: #172a46;
}

@media (hover: hover) and (pointer: fine) {
    html[data-theme="dark"] .add-set-toggle:hover {
        color: #e5e7eb;
        background: #1e293b;
        border-color: #64748b;
    }
}

@media (hover: none), (pointer: coarse) {
    html[data-theme="dark"] .add-set-toggle:active {
        color: #e5e7eb;
        background: #172033;
        border-color: #64748b;
    }
}
