:root {
    color-scheme: light;
    --ink: #f4f8fb;
    --muted: #aab8c4;
    --surface: rgba(28, 31, 34, 0.93);
    --surface-strong: rgba(255, 255, 255, 0.075);
    --line: rgba(37, 183, 234, 0.24);
    --syllax-blue: #25b7ea;
    --primary: #24313b;
    --primary-dark: #141b22;
    --primary-soft: rgba(37, 183, 234, 0.12);
    --syllax-dark: #202224;
    --accent: #d95f32;
    --exercise-green: #22c55e;
    --rest: #245f9f;
    --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    background:
        linear-gradient(90deg, rgba(16, 28, 38, 0.78), rgba(16, 28, 38, 0.28)),
        url("./pics/manplank2.jfif") center / cover no-repeat;
}

[hidden] {
    display: none !important;
}

.welcome-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 20% 12%, rgba(37, 183, 234, 0.28), transparent 32%),
        linear-gradient(135deg, rgba(12, 18, 24, 0.94), rgba(32, 34, 36, 0.88)),
        url("./pics/manplank2.jfif") center / cover no-repeat;
}

.welcome-content {
    position: relative;
    width: min(720px, 100%);
    border: 1px solid rgba(37, 183, 234, 0.34);
    border-radius: 8px;
    padding: clamp(24px, 5vw, 48px);
    color: #ffffff;
    background: rgba(20, 24, 28, 0.88);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.42);
    overflow: hidden;
    isolation: isolate;
}

.welcome-content::before {
    content: "";
    position: absolute;
    inset: 16px 18px auto auto;
    width: min(170px, 24%);
    aspect-ratio: 1;
    background: url("./SyllaxLogo.png") center / contain no-repeat;
    opacity: 0.28;
    pointer-events: none;
    z-index: 0;
}

.welcome-content > * {
    position: relative;
    z-index: 1;
}

.welcome-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.welcome-brand img {
    display: none;
}

.welcome-brand .eyebrow {
    margin: 0;
    color: var(--syllax-blue);
}

.welcome-content h1 {
    max-width: min(620px, calc(100% - 190px));
    color: #ffffff;
    font-size: clamp(34px, 7vw, 64px);
}

.welcome-copy {
    max-width: min(580px, calc(100% - 150px));
    margin: 18px 0 0;
    color: #d7e5ed;
    font-size: 18px;
    line-height: 1.55;
}

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 30px;
}

#welcomeLoadWorkoutInput {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.welcome-status {
    min-height: 22px;
    margin: 18px 0 0;
    color: #9de4ff;
    font-weight: 700;
}

.workout-library {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid rgba(37, 183, 234, 0.22);
}

.library-heading {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.library-heading h2 {
    color: #ffffff;
    font-size: clamp(22px, 4vw, 30px);
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.library-card {
    display: grid;
    gap: 10px;
    align-content: start;
    min-height: 100%;
    border: 1px solid rgba(37, 183, 234, 0.24);
    border-radius: 8px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.055);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.library-card h3,
.library-card p {
    margin: 0;
}

.library-card h3 {
    color: #ffffff;
    font-size: 18px;
}

.library-card p {
    color: #d7e5ed;
    line-height: 1.45;
}

.library-card .library-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.library-card button {
    width: 100%;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.08);
}

.library-card button:hover {
    background: rgba(37, 183, 234, 0.14);
}

.player-library {
    border-top: 1px solid var(--line);
    padding: 16px 24px 20px;
    background: rgba(255, 255, 255, 0.045);
}

.change-workout-button {
    width: 100%;
}

.workout-picker-panel {
    margin-top: 14px;
}

.player-library .library-heading h2 {
    font-size: 20px;
}

.compact-library {
    grid-template-columns: 1fr;
    max-height: 320px;
    overflow: auto;
    padding-right: 4px;
}

.compact-library .library-card {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 12px;
    gap: 8px 12px;
    align-items: center;
}

.compact-library .library-card h3 {
    font-size: 16px;
}

.compact-library .library-card p:not(.library-meta) {
    display: none;
}

.compact-library .library-meta {
    grid-column: 1;
}

.compact-library .library-card button {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: auto;
    min-height: 38px;
    white-space: nowrap;
}

.workout-active .player-library {
    display: none;
}

button,
input,
select {
    font: inherit;
}

button,
.file-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid rgba(37, 183, 234, 0.32);
    border-radius: 6px;
    padding: 10px 14px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover,
.file-button:hover {
    background: var(--primary-dark);
    border-color: rgba(37, 183, 234, 0.62);
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.secondary-button,
.icon-button {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.secondary-button:hover,
.icon-button:hover {
    background: rgba(37, 183, 234, 0.14);
}

.app-shell {
    width: min(1360px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 32px 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.95fr);
    gap: 24px;
    align-items: start;
}

.builder-panel,
.player-panel {
    border: 1px solid rgba(37, 183, 234, 0.22);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    min-width: 0;
}

.builder-panel {
    position: relative;
    padding: 24px;
    overflow: hidden;
    isolation: isolate;
}

.builder-panel::before {
    content: "";
    position: absolute;
    inset: 14px 16px auto auto;
    width: min(170px, 24%);
    aspect-ratio: 1;
    background: url("./SyllaxLogo.png") center / contain no-repeat;
    opacity: 0.28;
    pointer-events: none;
    z-index: 0;
}

.builder-panel > * {
    position: relative;
    z-index: 1;
}

.player-panel {
    position: sticky;
    top: 24px;
    overflow: hidden;
}

.panel-heading,
.workout-preview,
.timer-card {
    padding: 24px;
}

.panel-heading {
    display: grid;
    gap: 10px;
    max-width: min(620px, calc(100% - 180px));
}

.brand-lockup {
    display: flex;
    gap: 10px;
    align-items: center;
}

.brand-lockup img {
    display: none;
}

.brand-lockup .eyebrow {
    margin: 0;
}

#editWorkoutButton {
    justify-self: start;
}

.is-viewing ~ .status-message {
    margin-top: 12px;
}

.eyebrow,
.phase-label {
    margin: 0 0 6px;
    color: var(--syllax-blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.1;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 24px;
}

form {
    display: grid;
    gap: 22px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    border: 1px solid rgba(37, 183, 234, 0.16);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.checkbox-field {
    align-content: end;
}

.checkbox-field input {
    width: 24px;
    min-height: 24px;
}

input,
select {
    min-width: 0;
    width: 100%;
    min-height: 42px;
    border: 1px solid rgba(37, 183, 234, 0.2);
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.08);
}

input:focus,
select:focus {
    border-color: var(--syllax-blue);
    outline: 3px solid rgba(37, 183, 234, 0.2);
}

option {
    color: #17202a;
    background: #ffffff;
}

.section-heading,
.set-heading,
.actions,
.player-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.sets-container {
    display: grid;
    gap: 14px;
}

.set-card {
    display: grid;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface-strong);
    overflow: hidden;
}

.is-viewing .set-card {
    border-color: rgba(37, 183, 234, 0.2);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.set-heading {
    align-items: end;
}

.set-heading label {
    flex: 1;
}

.set-heading h3 {
    margin: 0;
    font-size: 18px;
    color: var(--ink);
}

.exercise-summary-list {
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
    color: var(--ink);
    font-weight: 700;
    list-style: none;
    counter-reset: exercise;
}

.exercise-summary-list li {
    counter-increment: exercise;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border-radius: 6px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.07);
}

.exercise-summary-list li:nth-child(even) {
    background: rgba(37, 183, 234, 0.09);
}

.exercise-summary-list li::before {
    content: counter(exercise);
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    color: #ffffff;
    background: rgba(37, 183, 234, 0.32);
    border: 1px solid rgba(37, 183, 234, 0.55);
    font-size: 12px;
}

.exercise-summary-list strong {
    color: var(--muted);
}

.is-viewing .field-grid {
    display: none;
}

.is-viewing #addSetButton {
    display: none;
}

.is-viewing #saveWorkoutButton,
.is-viewing #publishWorkoutButton,
.is-viewing #shareWorkoutButton,
.is-viewing #resetWorkoutButton {
    display: none;
}

.exercise-list {
    display: grid;
    gap: 12px;
    counter-reset: editable-exercise;
}

.exercise-row {
    counter-increment: editable-exercise;
    position: relative;
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(120px, 0.8fr) 86px 82px 112px;
    gap: 10px;
    align-items: end;
    border: 1px solid rgba(37, 183, 234, 0.16);
    border-radius: 8px;
    padding: 14px 14px 14px 48px;
    background: rgba(255, 255, 255, 0.045);
}

.exercise-row::before {
    content: counter(editable-exercise);
    position: absolute;
    top: 14px;
    left: 14px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(37, 183, 234, 0.5);
    border-radius: 999px;
    color: #ffffff;
    background: rgba(37, 183, 234, 0.24);
    font-size: 12px;
    font-weight: 800;
}

.custom-exercise-field[hidden] {
    display: none;
}

.custom-exercise-field {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.custom-exercise-field label {
    min-width: 0;
}

.cancel-custom-button {
    min-width: 72px;
    white-space: nowrap;
}

.exercise-row:has(.custom-exercise-field[hidden]) {
    grid-template-columns: minmax(130px, 1fr) 86px 82px 112px;
}

.exercise-row.has-custom-exercise {
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.2fr) 86px 82px;
}

.exercise-row.has-custom-exercise .exercise-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.exercise-row.has-custom-exercise .exercise-actions button {
    width: auto;
    min-width: 112px;
}

.icon-button {
    min-width: 80px;
}

.set-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(37, 183, 234, 0.16);
    padding-top: 12px;
}

.exercise-actions {
    display: grid;
    gap: 6px;
}

.exercise-actions button {
    width: 100%;
    min-width: 0;
}

.split-set-button {
    min-height: 38px;
    padding: 8px;
    line-height: 1.1;
}

.toggle-field {
    justify-items: center;
    gap: 6px;
}

.toggle-field input {
    width: 24px;
    min-height: 24px;
}

.add-exercise,
.set-actions button {
    justify-self: start;
}

.actions {
    flex-wrap: wrap;
    justify-content: flex-start;
}

#loadWorkoutInput {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.status-message {
    min-height: 22px;
    margin: 18px 0 0;
    color: #9de4ff;
    font-size: 14px;
    font-weight: 700;
}

.workout-preview {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.055);
}

.workout-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.workout-active .workout-summary {
    display: none;
}

.workout-summary div {
    display: grid;
    gap: 2px;
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.07);
}

.workout-summary strong {
    font-size: 22px;
}

.workout-summary span,
.up-next {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.completion-message {
    max-width: 520px;
    margin: 0 auto;
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.35;
}

.live-workout-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: min(520px, 100%);
    margin: 0 auto;
}

.live-workout-stats:empty {
    display: none;
}

.live-workout-stats div {
    display: grid;
    gap: 2px;
    border: 1px solid rgba(37, 183, 234, 0.24);
    border-radius: 8px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.075);
}

.live-workout-stats strong {
    color: #ffffff;
    font-size: 18px;
}

.live-workout-stats span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.timer-card {
    min-height: 420px;
    display: grid;
    align-content: center;
    gap: 16px;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(28, 31, 34, 0.86), rgba(28, 31, 34, 0.74)),
        url("./pics/mount2.jfif") center / cover no-repeat;
}

.workout-active .timer-card {
    min-height: 520px;
}

#counter {
    min-height: 130px;
    color: var(--ink);
    font-size: clamp(72px, 11vw, 132px);
    font-weight: 900;
    line-height: 1;
}

#counter[data-phase="prep"] {
    color: #ff5a5f;
}

#counter[data-phase="exercise"] {
    color: var(--exercise-green);
}

#counter[data-phase="rest"] {
    color: var(--rest);
}

.player-actions {
    justify-content: center;
    flex-wrap: wrap;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(5, 9, 12, 0.72);
}

.exercise-help-modal {
    position: relative;
    width: min(620px, 100%);
    max-height: min(860px, calc(100vh - 36px));
    overflow: auto;
    border: 1px solid rgba(37, 183, 234, 0.34);
    border-radius: 8px;
    padding: 24px;
    color: var(--ink);
    background: rgba(28, 31, 34, 0.98);
    box-shadow: var(--shadow);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    min-height: 36px;
    padding: 7px 10px;
}

.exercise-help-modal h2 {
    margin-right: 86px;
}

.exercise-help-media {
    margin-top: 18px;
}

.exercise-help-media:empty {
    display: none;
}

.exercise-help-media img {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.exercise-help-content ol {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding-left: 22px;
    color: #d7e5ed;
    line-height: 1.45;
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
        width: min(100% - 20px, 620px);
        padding: 10px 0 20px;
    }

    .player-panel {
        position: static;
    }

    .workout-active .builder-panel {
        display: none;
    }

    .workout-active .player-panel {
        order: -1;
    }

    .workout-active .timer-card {
        min-height: calc(100vh - 40px);
    }
}

@media (max-width: 560px) {
    .welcome-screen {
        align-items: start;
        padding: 12px;
    }

    .welcome-brand {
        align-items: flex-start;
        flex-direction: column;
    }

    .welcome-content {
        padding: 22px;
    }

    .welcome-content::before {
        inset: 12px 10px auto auto;
        width: 34%;
        opacity: 0.22;
    }

    .welcome-content h1 {
        max-width: 100%;
        font-size: clamp(36px, 13vw, 52px);
    }

    .welcome-copy {
        max-width: 100%;
        margin-top: 20px;
        font-size: 18px;
        line-height: 1.55;
    }

    .welcome-actions {
        display: grid;
        gap: 12px;
        margin-top: 26px;
        border: 1px solid rgba(37, 183, 234, 0.18);
        border-radius: 8px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.045);
    }

    .welcome-actions button,
    .welcome-actions .file-button {
        width: 100%;
    }

    .workout-library {
        margin-top: 26px;
        border: 1px solid rgba(37, 183, 234, 0.2);
        border-radius: 8px;
        padding: 14px;
        background: rgba(255, 255, 255, 0.04);
    }

    .library-heading {
        border-bottom: 1px solid rgba(37, 183, 234, 0.18);
        padding-bottom: 12px;
    }

    .library-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .library-card {
        gap: 12px;
        border-color: rgba(37, 183, 234, 0.34);
        padding: 16px;
    }

    .library-card + .library-card {
        margin-top: 2px;
    }

    .library-card h3 {
        font-size: 24px;
    }

    .library-card p {
        font-size: 15px;
    }

    .library-card .library-meta {
        border-top: 1px solid rgba(37, 183, 234, 0.16);
        padding-top: 10px;
        font-size: 13px;
    }

    .library-card button {
        width: 100%;
        margin-top: 2px;
    }

    .compact-library .library-card {
        grid-template-columns: 1fr;
        border: 1px solid rgba(37, 183, 234, 0.34);
        border-radius: 8px;
        padding: 14px;
        background: rgba(255, 255, 255, 0.065);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    }

    .compact-library .library-card button,
    .compact-library .library-meta {
        grid-column: auto;
        grid-row: auto;
    }

    .compact-library .library-card button {
        width: 100%;
    }

    .player-library {
        border-top: 1px solid rgba(37, 183, 234, 0.3);
        background: rgba(10, 18, 24, 0.62);
    }

    .workout-picker-panel {
        border: 1px solid rgba(37, 183, 234, 0.24);
        border-radius: 8px;
        padding: 14px;
        background: rgba(5, 10, 14, 0.34);
    }

    .compact-library {
        max-height: 420px;
        overflow-y: auto;
        padding-right: 0;
    }

    .builder-panel,
    .panel-heading,
    .workout-preview,
    .player-library,
    .timer-card {
        padding: 16px;
    }

    .panel-heading {
        max-width: 100%;
    }

    h1 {
        font-size: 26px;
    }

    .field-grid,
    .workout-summary {
        grid-template-columns: 1fr 1fr;
    }

    .live-workout-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        width: 100%;
    }

    .live-workout-stats div {
        min-width: 0;
        border-color: rgba(37, 183, 234, 0.38);
        padding: 8px 4px;
        background: rgba(10, 18, 24, 0.62);
    }

    .live-workout-stats strong {
        font-size: 16px;
        line-height: 1;
    }

    .live-workout-stats span {
        font-size: 9px;
        line-height: 1.1;
    }

    .modal-backdrop {
        align-items: start;
        justify-items: center;
        padding: 10px;
        overflow: auto;
    }

    .exercise-help-modal {
        width: 100%;
        max-width: calc(100vw - 20px);
        max-height: none;
        overflow-x: hidden;
        padding: 16px;
    }

    .modal-close {
        position: static;
        width: auto;
        margin: 0 0 12px;
    }

    .exercise-help-modal h2 {
        margin-right: 0;
        font-size: 32px;
    }

    .exercise-help-media {
        margin-top: 14px;
        overflow: hidden;
        border-radius: 8px;
    }

    .exercise-help-media img {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .exercise-help-content ol {
        padding-left: 20px;
        font-size: 15px;
    }

    .field-grid {
        padding: 12px;
    }

    .exercise-row {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 12px;
        padding: 48px 12px 12px;
        background:
            linear-gradient(180deg, rgba(37, 183, 234, 0.09), rgba(255, 255, 255, 0.045) 42px),
            rgba(255, 255, 255, 0.045);
    }

    .exercise-row:has(.custom-exercise-field[hidden]) {
        grid-template-columns: 1fr;
    }

    .exercise-row::before {
        top: 12px;
        left: 12px;
    }

    .exercise-row::after {
        content: "Exercise " counter(editable-exercise);
        position: absolute;
        top: 16px;
        left: 46px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .custom-exercise-field {
        grid-template-columns: 1fr;
    }

    .toggle-field {
        display: flex;
        min-height: 44px;
        align-items: center;
        justify-content: space-between;
        border: 1px solid rgba(37, 183, 234, 0.14);
        border-radius: 6px;
        padding: 9px 10px;
        background: rgba(255, 255, 255, 0.045);
    }

    .section-heading,
    .set-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .set-card {
        gap: 16px;
        padding: 12px;
    }

    .set-heading {
        border-bottom: 1px solid rgba(37, 183, 234, 0.16);
        padding-bottom: 12px;
    }

    .actions button,
    .actions .file-button,
    .player-actions button,
    .exercise-actions button,
    .set-actions button {
        width: 100%;
    }
}

