body {
    margin: 0;
    padding: 0.5rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    body {
        padding: 2rem;
    }
}

h1 {
    color: #333;
    margin: 0;
    text-align: center;
    flex: 1;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    position: relative;
}

.theme-toggle {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* Default: show moon in light mode */
.theme-toggle .dark-icon {
    display: none;
}

.theme-toggle .light-icon {
    display: inline;
}

/* System dark mode: show sun */
@media (prefers-color-scheme: dark) {
    html:not(.light) .theme-toggle .light-icon {
        display: none;
    }

    html:not(.light) .theme-toggle .dark-icon {
        display: inline;
    }
}

/* Manual dark mode: show sun */
html.dark .theme-toggle .light-icon {
    display: none;
}

html.dark .theme-toggle .dark-icon {
    display: inline;
}

/* Manual light mode: show moon */
html.light .theme-toggle .light-icon {
    display: inline;
}

html.light .theme-toggle .dark-icon {
    display: none;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 0.5rem;
    position: relative;
    min-height: 40px;
}

.nav-btn {
    padding: 0.5rem 0.75rem;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
    flex-shrink: 0;
    z-index: 1;
    min-width: 50px;
    text-align: center;
}

@media (min-width: 768px) {
    .nav-btn {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

.nav-btn:hover {
    background: #0051D5;
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.date-picker {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 2px solid #007AFF;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 200px;
}

@media (min-width: 768px) {
    .date-picker {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

.workout-content {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

@media (min-width: 768px) {
    .workout-content {
        padding: 1.5rem;
    }
}

.workout-section {
    margin-bottom: 2rem;
}

.workout-section:last-child {
    margin-bottom: 0;
}

.workout-section details {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0;
    background: white;
}

.workout-section details[open] {
    padding-bottom: 1rem;
}

.workout-section summary {
    cursor: pointer;
    user-select: none;
    padding: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.workout-section summary:hover {
    background-color: #f8f9fa;
}

.workout-section details[open] summary {
    border-bottom: 1px solid #e0e0e0;
    border-radius: 6px 6px 0 0;
}

.workout-section summary::marker {
    font-size: 1.2rem;
}

/* Content inside details */
.workout-section details > div,
.workout-section details > details {
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Nested subsection details */
.subsection {
    margin: 0.75rem 0;
    border: none;
    background: transparent;
}

.subsection summary {
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    font-weight: 600;
    color: #555;
    margin: 0;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}

.subsection summary:hover {
    color: #007AFF;
}

.subsection summary::marker {
    font-size: 0.9rem;
}

.subsection[open] {
    padding-bottom: 0.5rem;
}

.subsection > div {
    padding-left: 1rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 0.5rem 0;
}

.duration {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
}

.subsection-title {
    font-weight: 600;
    color: #555;
    margin: 1rem 0 0.5rem 0;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.workout-line {
    line-height: 1.6;
    color: #333;
}

.workout-separator {
    height: 2px;
    background: #e0e0e0;
    margin: 2rem 0;
    border-radius: 1px;
}

.loading {
    text-align: center;
    color: #999;
    font-style: italic;
}

.error {
    color: #e74c3c;
    text-align: center;
}

/* Dark mode - system preference */
@media (prefers-color-scheme: dark) {
    html:not(.light) body {
        background: #000;
        color: #fff;
    }

    html:not(.light) h1 {
        color: #fff;
    }

    html:not(.light) .date-picker {
        background: #1c1c1e;
        color: #fff;
        border-color: #007AFF;
    }

    html:not(.light) .workout-content {
        background: #1c1c1e;
        color: #fff;
    }

    html:not(.light) .workout-section details {
        background: #2c2c2e;
        border-color: #3a3a3c;
    }

    html:not(.light) .workout-section summary {
        color: #fff;
    }

    html:not(.light) .workout-section summary:hover {
        background-color: #3a3a3c;
    }

    html:not(.light) .workout-section details[open] summary {
        border-bottom-color: #3a3a3c;
    }

    html:not(.light) .subsection summary {
        color: #b0b0b0;
    }

    html:not(.light) .subsection summary:hover {
        color: #007AFF;
    }

    html:not(.light) .section-title {
        color: #fff;
    }

    html:not(.light) .subsection-title {
        color: #b0b0b0;
    }

    html:not(.light) .workout-line {
        color: #fff;
    }

    html:not(.light) .duration {
        color: #b0b0b0;
    }

    html:not(.light) .workout-separator {
        background: #3a3a3c;
    }

    html:not(.light) .nav-btn:disabled {
        background: #3a3a3c;
        color: #8e8e93;
    }

    html:not(.light) .loading {
        color: #8e8e93;
    }
}

/* Dark mode - manual override */
html.dark body {
    background: #000;
    color: #fff;
}

html.dark h1 {
    color: #fff;
}

html.dark .date-picker {
    background: #1c1c1e;
    color: #fff;
    border-color: #007AFF;
}

html.dark .workout-content {
    background: #1c1c1e;
    color: #fff;
}

html.dark .workout-section details {
    background: #2c2c2e;
    border-color: #3a3a3c;
}

html.dark .workout-section summary {
    color: #fff;
}

html.dark .workout-section summary:hover {
    background-color: #3a3a3c;
}

html.dark .workout-section details[open] summary {
    border-bottom-color: #3a3a3c;
}

html.dark .subsection summary {
    color: #b0b0b0;
}

html.dark .subsection summary:hover {
    color: #007AFF;
}

html.dark .section-title {
    color: #fff;
}

html.dark .subsection-title {
    color: #b0b0b0;
}

html.dark .workout-line {
    color: #fff;
}

html.dark .duration {
    color: #b0b0b0;
}

html.dark .workout-separator {
    background: #3a3a3c;
}

html.dark .nav-btn:disabled {
    background: #3a3a3c;
    color: #8e8e93;
}

html.dark .loading {
    color: #8e8e93;
}
