: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;
    --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: 10px 8px auto auto;
    width: min(220px, 32%);
    aspect-ratio: 1;
    background: url("./SyllaxLogo.png") center / contain no-repeat;
    opacity: 0.34;
    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: 620px;
    color: #ffffff;
    font-size: clamp(34px, 7vw, 64px);
}

.welcome-copy {
    max-width: 580px;
    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;
}

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: 10px 8px auto auto;
    width: min(220px, 32%);
    aspect-ratio: 1;
    background: url("./SyllaxLogo.png") center / contain no-repeat;
    opacity: 0.34;
    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;
}

.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;
}

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 #resetWorkoutButton {
    display: none;
}

.exercise-list {
    display: grid;
    gap: 10px;
}

.exercise-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) minmax(120px, 0.8fr) 86px 82px 112px;
    gap: 10px;
    align-items: end;
}

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

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

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

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

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

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

.set-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.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;
}

.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(--syllax-blue);
}

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

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

@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 {
        padding: 14px;
    }

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

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

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

    h1 {
        font-size: 26px;
    }

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

    .exercise-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

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

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

    .toggle-field {
        justify-items: start;
    }

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

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