:root {
    --color-orange: darkorange;
    --color-green: darkgreen;
    --color-white: #ffffff;
    --color-text: #333333;
    --color-border: #e0e0e0;
    --color-border-hover: #d0d0d0;
    --color-soft-bg: #f9f9f9;
    --color-dashed: #dddddd;

    --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-panel-hover: 0 6px 32px rgba(0, 0, 0, 0.12);
    --shadow-selected: 0 4px 12px rgba(0, 0, 0, 0.2);

    --radius-panel: 12px;
    --radius-card: 10px;
    --radius-button: 8px;
    --radius-chariot: 10px;

    --font-base: Arial, Helvetica, sans-serif;

    --chariot-width: 110px;
    --chariot-height: 70px;
    --carousel-gap: 10px;
    --vertical-carousel-height: 300px;
    --vertical-carousel-height-mobile: 250px;
}

/* ============================= */
/*            BASICS             */
/* ============================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-base);
    background: #f3f3f3;
    color: var(--color-text);
}

#panel,
.chariots,
.chariots p,
.top-btn,
.overview-table button,
.progress-buttons button {
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease,
        border-color 0.2s ease;
}

/* ============================= */
/*         WORKOUT-PANEL         */
/* ============================= */

#panel {
    width: min(100% - 16px, 640px);
    margin: 12px auto 20px;
    padding: 16px 12px 20px;
    overflow: visible;
    background: var(--color-white);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-panel);
}

#panel:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-panel-hover);
}

/* ============================= */
/*          TOPP-HEADER          */
/* ============================= */

.top-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0.5rem;
}

.left-side {
    width: 100%;
}

.top-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.top-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--radius-button);
    background-color: var(--color-orange);
    color: var(--color-white);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.top-btn:hover,
.top-btn:focus-visible {
    background-color: var(--color-green);
}

.top-btn:focus-visible {
    outline: 2px solid rgba(0, 100, 0, 0.25);
    outline-offset: 2px;
}

/* ============================= */
/*        TITLAR / TEXTER        */
/* ============================= */

.page-title {
    margin: 0.4rem 0 0.2rem;
    color: var(--color-orange);
    font-size: 2.1rem;
    font-weight: 700;
    text-align: center;
}

.exercise-subtitle {
    margin: 0 0 0.9rem;
    color: var(--color-green);
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    min-height: 1.4em;
}

.title-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin: 0.35rem 0 0.9rem;
    text-align: center;
}

.title-row .page-title,
.title-row .exercise-subtitle {
    margin: 0;
    min-height: 0;
}

.selection-display {
    display: flex;
    flex-direction: column;
    margin: 20px 0;
    text-align: center;
}

.selection-display p {
    margin: 10px 0;
    color: var(--color-text);
    font-size: 1.2em;
}

.progress-info {
    margin-top: 15px;
    text-align: center;
}

/* ============================= */
/*           LAYOUT              */
/* ============================= */

#carousels-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
    position: relative;
    isolation: isolate;
}

.carousel-block {
    position: relative;
    z-index: 0;
    width: 100%;
}

.carousel-block.is-exercise {
    margin-top: 2px;
}

.carousel-block.is-weight,
.carousel-block.is-reps {
    overflow: hidden;
}

.carousel-label {
    margin: 0 0 6px;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

/* ============================= */
/*      HORISONTELL KARUSELL     */
/* ============================= */

.carousel-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    touch-action: pan-y pinch-zoom;
    border-radius: 12px;
}

.carousel-container::-webkit-scrollbar {
    display: none;
}

.carousel-container.is-pointer-down {
    cursor: grabbing;
}

.carousel {
    display: flex;
    flex-direction: row;
    gap: var(--carousel-gap);
    user-select: none;
}

.chariots {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--chariot-height);
    background-color: var(--color-orange);
    border: 2px solid transparent;
    border-radius: var(--radius-chariot);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: scale(1);
    position: relative;
    z-index: 1;
    cursor: pointer;
}

.carousel-container:not(.carousel-container-vertical) .carousel {
    min-width: max-content;
    padding: 10px calc((100% - var(--chariot-width)) / 2);
}

.carousel-container:not(.carousel-container-vertical) .chariots {
    width: var(--chariot-width);
    flex: 0 0 var(--chariot-width);
}

.chariots.selected {
    z-index: 2;
    background-color: var(--color-green);
    border-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.03);
    box-shadow: var(--shadow-selected);
}

.chariots p {
    margin: 0;
    color: var(--color-white);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.1;
    pointer-events: none;
    padding: 0 6px;
    word-break: break-word;
}

.chariots:focus-visible {
    outline: 2px solid rgba(0, 100, 0, 0.3);
    outline-offset: 2px;
}

/* ============================= */
/*   VERTIKAL KARUSELL (övningar)*/
/* ============================= */

.carousel-container-vertical {
    height: var(--vertical-carousel-height);
    width: 100%;
    overflow: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.carousel-container-vertical .carousel {
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: calc((var(--vertical-carousel-height) - var(--chariot-height)) / 2);
    padding-left: 0;
    padding-right: 0;
    padding-bottom: calc((var(--vertical-carousel-height) - var(--chariot-height)) / 2);
    gap: 2px;
    scrollbar-width: none;
}

.carousel-container-vertical .carousel::-webkit-scrollbar {
    display: none;
}

.carousel-container-vertical .chariots {
    flex: 0 0 var(--chariot-height);
    width: 100%;
    max-width: 100%;
    min-width: 100%;
    margin: 2px 0;
    box-sizing: border-box;
}

.chariot-spacer {
    flex: 0 0 auto;
    width: 100%;
    pointer-events: none;
}

/* ============================= */
/*            TABELL             */
/* ============================= */

.overview-table {
    width: 100%;
    margin: 0 auto 1rem;
    overflow: hidden;
    background-color: var(--color-white);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--radius-card);
    font-size: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.overview-table th {
    padding: 10px 10px;
    background-color: var(--color-orange);
    color: var(--color-white);
    font-weight: 700;
    text-align: center;
}

.overview-table th:first-child {
    width: 34%;
}

.overview-table td {
    padding: 10px 10px;
    color: var(--color-green);
    font-size: 1rem;
    text-align: center;
    background-color: var(--color-white);
    border-top: 1px solid #f0f0f0;
}

.overview-table td:first-child {
    color: var(--color-orange);
    font-weight: 700;
    text-align: left;
}

.overview-table button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-button);
    background-color: var(--color-orange);
    color: var(--color-white);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.overview-table button:hover,
.overview-table button:focus-visible {
    background-color: var(--color-green);
}

.overview-table button:focus-visible {
    outline: 2px solid rgba(0, 100, 0, 0.25);
    outline-offset: 2px;
}

.overview-table-compact th:first-child {
    width: 22%;
}

.overview-table-compact td:first-child {
    white-space: nowrap;
}

/* ============================= */
/*            KNAPPAR            */
/* ============================= */

.progress-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 8px 0 6px;
}

.progress-buttons button {
    min-height: 58px;
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius-button);
    background-color: var(--color-green);
    color: var(--color-white);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 100, 0, 0.18);
}

.progress-buttons button:disabled {
    cursor: wait;
    opacity: 0.88;
}

.progress-buttons-inline {
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 2px;
}

.progress-buttons-inline button {
    flex: 1 1 0;
    min-height: 48px;
    padding: 10px 14px;
    font-size: 0.98rem;
}

.progress-buttons-inline .secondary-action {
    background-color: var(--color-orange);
    box-shadow: 0 4px 10px rgba(255, 140, 0, 0.18);
}

.progress-buttons-inline .secondary-action:hover,
.progress-buttons-inline .secondary-action:focus-visible {
    background-color: var(--color-green);
}

.progress-buttons button.is-saving {
    transform: scale(0.99);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.progress-buttons button:hover,
.progress-buttons button:focus-visible {
    background-color: var(--color-orange);
    transform: translateY(-1px);
}

.progress-buttons button:focus-visible {
    outline: 2px solid rgba(255, 140, 0, 0.3);
    outline-offset: 2px;
}

#save-status {
    min-height: 1.4em;
    margin: 6px 0 0;
    color: var(--color-green);
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

#save-status.is-idle,
#save-status.is-loading,
#save-status.is-success,
#save-status.is-error {
    opacity: 1;
    transform: translateY(0);
}

#save-status.is-loading {
    color: #5d5d5d;
}

#save-status.is-success {
    color: var(--color-green);
}

#save-status.is-error {
    color: #b42318;
}

.pulse-update {
    animation: pulseUpdate 0.55s ease;
}

#panel > *:not(script) {
    animation: fadeLiftIn 0.4s ease both;
}

#panel > *:nth-child(2) {
    animation-delay: 0.03s;
}

#panel > *:nth-child(3) {
    animation-delay: 0.06s;
}

#panel > *:nth-child(4) {
    animation-delay: 0.09s;
}

#panel > *:nth-child(5) {
    animation-delay: 0.12s;
}

@keyframes pulseUpdate {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    40% {
        transform: scale(1.04);
        filter: brightness(1.08);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

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

/* ============================= */
/*      AKTUELLT ESTIMERAT MAX   */
/* ============================= */

.estimated-max-box {
    margin-top: 10px;
    padding: 12px 10px;
    border: 1px dashed var(--color-dashed);
    border-radius: 10px;
    background-color: var(--color-soft-bg);
    font-size: 1rem;
    text-align: center;
}

.estimated-max-label {
    margin-right: 4px;
    color: var(--color-text);
}

#current-estimated-max-value {
    color: var(--color-green);
    font-weight: 700;
}

.workout-footer-logo {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.top-logo {
    max-width: 110px;
    width: 100%;
    height: auto;
}

/* ============================= */
/*         LANDNINGSSIDA         */
/* ============================= */

:root {
    --landing-bg: linear-gradient(135deg, #0c2f24, #0f4d32 55%, #f28c28 120%);
    --card-bg: rgba(255, 255, 255, 0.92);
    --accent: #f28c28;
    --accent-strong: #d96a00;
    --contrast: #0f4d32;
    --text-main: #0f1f1c;
    --muted: #3f5c54;
    --surface-shadow: 0 14px 50px rgba(0, 0, 0, 0.12);
}

.landing-body {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--landing-bg);
    color: var(--text-main);
    font-family: 'Poppins', 'Segoe UI', sans-serif;
}

.landing-shell {
    position: relative;
    z-index: 1;
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.landing-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
    color: #f6fbf8;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-meta .title {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
}

.brand-meta .subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

.landing-link {
    position: relative;
    z-index: 2;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.landing-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hero {
    margin-top: 32px;
    padding: 28px 24px 32px;
    border-radius: 22px;
    background: var(--card-bg);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(6px);
}

.hero h1 {
    margin: 0 0 10px;
    color: var(--contrast);
    font-size: 2rem;
}

.hero p {
    max-width: 720px;
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.5;
}

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

.landing-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.landing-btn.primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 26px rgba(242, 140, 40, 0.35);
}

.landing-btn.primary:hover {
    background: var(--accent-strong);
    transform: translateY(-2px);
}

.landing-btn.secondary {
    background: #0f4d32;
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 77, 50, 0.35);
}

.landing-btn.secondary:hover {
    background: #0c3e2a;
    transform: translateY(-2px);
}

.landing-btn.ghost {
    border-color: rgba(15, 77, 50, 0.2);
    background: rgba(15, 77, 50, 0.08);
    color: var(--contrast);
}

.landing-btn.ghost:hover {
    background: rgba(15, 77, 50, 0.15);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-top: 28px;
}

.feature-card {
    padding: 18px 18px 20px;
    border: 1px solid rgba(15, 77, 50, 0.06);
    border-radius: 16px;
    background: var(--card-bg);
    box-shadow: var(--surface-shadow);
}

.feature-card .badge {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: rgba(242, 140, 40, 0.15);
    color: var(--accent-strong);
    font-weight: 700;
}

.feature-card h3 {
    margin: 0 0 6px;
    color: var(--contrast);
    font-size: 1.05rem;
}

.feature-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.45;
}

.quick-section {
    margin-top: 26px;
    padding: 16px;
    border: 1px solid rgba(15, 77, 50, 0.18);
    border-radius: 14px;
    background: rgba(15, 77, 50, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

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

.quick-card {
    padding: 14px 14px 16px;
    border: 1px solid rgba(15, 77, 50, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.quick-card h4 {
    margin: 0 0 6px;
    color: var(--contrast);
}

.quick-card p {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.95rem;
}

.quick-card .link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-card .mini-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid rgba(242, 140, 40, 0.18);
    border-radius: 10px;
    background: rgba(242, 140, 40, 0.16);
    color: var(--contrast);
    font-weight: 600;
    text-decoration: none;
}

.quick-card .mini-link:hover {
    background: rgba(242, 140, 40, 0.26);
}

.landing-footer {
    margin-top: 26px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: center;
}

.landing-bubble {
    position: absolute;
    z-index: 0;
    border-radius: 999px;
    filter: blur(40px);
    opacity: 0.5;
}

.bubble-one {
    top: -80px;
    right: -120px;
    width: 360px;
    height: 360px;
    background: rgba(242, 140, 40, 0.45);
}

.bubble-two {
    bottom: -60px;
    left: -100px;
    width: 280px;
    height: 280px;
    background: rgba(15, 77, 50, 0.55);
}

/* ============================= */
/*           RESPONSIVT          */
/* ============================= */

@media (max-width: 900px) and (orientation: landscape) {
    #panel {
        width: min(100% - 24px, 80%);
        padding: 16px 14px 20px;
    }

    .carousel-container:not(.carousel-container-vertical) .chariots {
        width: 95px;
        flex-basis: 95px;
        height: 48px;
    }

    .carousel-container:not(.carousel-container-vertical) .carousel {
        padding: 10px calc((100% - 95px) / 2);
    }
}

@media (min-width: 901px) {
    #panel {
        width: min(100% - 24px, 640px);
    }

    .carousel-container-vertical .chariots p {
        font-size: 0.95rem;
        padding: 0 10px;
    }

    .carousel-container-vertical .chariots {
        min-height: 50px;
        height: 50px;
        flex: 0 0 70px;
    }
}

@media (max-width: 640px) {
    .hero {
        padding: 22px 18px 26px;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .landing-header {
        padding: 16px 12px 0;
    }

    .landing-link {
        padding: 7px 12px;
    }
}

@media (max-width: 600px) {
    #panel {
        width: calc(100% - 12px);
        padding: 12px 8px 18px;
        margin-top: 8px;
    }

    .top-header {
        margin-bottom: 0.3rem;
    }

    .top-buttons {
        gap: 6px;
    }

    .top-btn {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .title-row {
        gap: 8px;
        margin: 0.2rem 0 0.6rem;
    }

    .page-title {
        margin: 0;
        font-size: 1.9rem;
    }

    .exercise-subtitle {
        margin: 0;
        font-size: 1rem;
    }

    .overview-table-compact {
        font-size: 0.84rem;
    }

    .overview-table-compact th,
    .overview-table-compact td {
        padding: 8px 4px;
        font-size: 0.84rem;
    }

    .overview-table-compact th:first-child,
    .overview-table-compact td:first-child {
        width: 24%;
        font-size: 0.82rem;
    }

    .progress-buttons-inline {
        gap: 8px;
        margin: 4px 0 0;
    }

    .progress-buttons-inline button {
        min-height: 40px;
        padding: 6px 8px;
        font-size: 0.84rem;
    }

    #carousels-area {
        margin-top: 2px;
        gap: 10px;
    }

    .carousel-container:not(.carousel-container-vertical) .carousel {
        padding: 8px calc((100% - 92px) / 2);
    }

    .carousel-container-vertical {
        height: var(--vertical-carousel-height-mobile);
    }

    .carousel-container:not(.carousel-container-vertical) .chariots {
        width: 92px;
        flex-basis: 92px;
        height: 48px;
    }

    .carousel-container-vertical .chariots {
        width: 100%;
        flex-basis: 48px;
    }

    .chariots p {
        font-size: 0.9rem;
    }

    .overview-table {
        margin-bottom: 0.7rem;
    }

    .overview-table th,
    .overview-table td {
        padding: 8px 6px;
        font-size: 0.9rem;
    }

    .overview-table button {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .progress-buttons button {
        min-height: 50px;
        padding: 10px 18px;
        font-size: 0.95rem;
    }

    .estimated-max-box {
        margin-top: 8px;
        padding: 10px 8px;
        font-size: 0.92rem;
    }

    .top-logo {
        max-width: 90px;
    }

    .carousel-container-vertical .carousel {
        padding-top: calc((var(--vertical-carousel-height-mobile) - 48px) / 2);
        padding-bottom: calc((var(--vertical-carousel-height-mobile) - 48px) / 2);
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    #panel {
        width: calc(100% - 12px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #panel > *:not(script),
    .pulse-update {
        animation: none !important;
    }

    #save-status,
    #panel,
    .chariots,
    .progress-buttons button,
    .overview-table button,
    .top-btn {
        transition: none !important;
    }
}

