/* A shared page theme; workout colors keep their meaning in both modes. */
:root { color-scheme: light; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    gap: 8px;
    padding: 0 12px;
}
.theme-label { font-size: .875rem; font-weight: 600; }
.theme-sun { display: none; }
[data-bs-theme="dark"] .theme-sun { display: block; }
[data-bs-theme="dark"] .theme-moon { display: none; }
.brand .brand-logo-dark { display: none; }
[data-bs-theme="dark"] .brand .brand-logo-light { display: none; }
[data-bs-theme="dark"] .brand .brand-logo-dark { display: block; }

:root[data-bs-theme="dark"] {
    color-scheme: dark;
    --ink: #edf3fb;
    --muted: #adbbce;
    --line: #314157;
    --paper: #0d1522;
    --blue: #8bbaff;
    --green: #76e6a0;
    --orange: #ffbc74;
    --purple: #c6a6ff;
    --surface: #172335;
    --input-surface: #101b2b;
    --hover-surface: #253951;
    --bs-body-bg: var(--paper);
    --bs-body-bg-rgb: 13, 21, 34;
    --bs-body-color: var(--ink);
    --bs-body-color-rgb: 237, 243, 251;
    --bs-secondary-color: var(--muted);
    --bs-secondary-color-rgb: 173, 187, 206;
    --bs-secondary-rgb: 173, 187, 206;
    --bs-secondary-bg: #253348;
    --bs-tertiary-bg: #1d2b3e;
    --bs-emphasis-color: #f5f8ff;
    --bs-emphasis-color-rgb: 245, 248, 255;
    --bs-border-color: var(--line);
    --bs-heading-color: var(--ink);
}

[data-bs-theme="dark"] .site-header { background: #101b2b; }
[data-bs-theme="dark"] .surface,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .icon-button,
[data-bs-theme="dark"] .skip-link { background: var(--surface); color: var(--ink); }
[data-bs-theme="dark"] .setting-row { border-color: var(--line); }
[data-bs-theme="dark"] .heading-mark { border-color: var(--line); color: var(--muted); }
[data-bs-theme="dark"] .section-number { background: #273b56; color: #c6d8f0; }
[data-bs-theme="dark"] .number-control,
[data-bs-theme="dark"] .beep-frequency .form-control { background: var(--input-surface); color: var(--ink); border-color: var(--line); }
[data-bs-theme="dark"] .number-control > button { color: var(--muted); }
[data-bs-theme="dark"] .number-control > button:hover { background: var(--hover-surface); color: var(--blue); }
[data-bs-theme="dark"] .number-value input:invalid { color: #ff9ea9; }
[data-bs-theme="dark"] .form-switch .form-check-input { border-color: #6d819d; }
[data-bs-theme="dark"] .form-switch .form-check-input:checked { border-color: var(--blue); }
[data-bs-theme="dark"] .form-range::-webkit-slider-runnable-track { background: #435570; }
[data-bs-theme="dark"] .form-range::-moz-range-track { background: #435570; }
[data-bs-theme="dark"] .coach-note-icon { background: #233c5c; }
[data-bs-theme="dark"] .muted-icon { color: var(--muted); }
[data-bs-theme="dark"] .site-footer,
[data-bs-theme="dark"] .site-footer > span:first-child { color: var(--muted); }

[data-bs-theme="dark"] .workout-summary { background: #162c49; box-shadow: none; }
[data-bs-theme="dark"] .icon-button[aria-pressed="true"] { background: #28446b; color: #bed8ff; border-color: #526e97; }
[data-bs-theme="dark"] .icon-button:hover,
[data-bs-theme="dark"] .secondary-button:hover { background: var(--hover-surface); color: var(--ink); border-color: #6682a6; }
[data-bs-theme="dark"] .primary-button { background: #8bbaff; border-color: #8bbaff; color: #0b1c34; }
[data-bs-theme="dark"] .primary-button:hover,
[data-bs-theme="dark"] .primary-button:focus-visible { background: #b2d2ff; border-color: #b2d2ff; color: #0b1c34; }
[data-bs-theme="dark"] .secondary-button { background: var(--surface); color: var(--ink); border-color: #506680; }
[data-bs-theme="dark"] button:focus-visible,
[data-bs-theme="dark"] a:focus-visible,
[data-bs-theme="dark"] input:focus-visible { outline-color: #a8caff; }

[data-bs-theme="dark"] .timer-stage {
    --phase: #9fc5ff;
    --phase-bg: #142d4b;
    border-color: color-mix(in srgb, var(--phase) 32%, #172335);
}
[data-bs-theme="dark"] .timer-stage[data-phase="active"] { --phase: #7aeca7; --phase-bg: #123628; }
[data-bs-theme="dark"] .timer-stage[data-phase="transition"] { --phase: #ffca8e; --phase-bg: #3c2a17; }
[data-bs-theme="dark"] .timer-stage[data-phase="rest"] { --phase: #d0b2ff; --phase-bg: #302044; }
[data-bs-theme="dark"] .timer-stage.is-paused { --phase: #d0dfef; --phase-bg: #253344; }
[data-bs-theme="dark"] .next-phase { background: #0d152299; border-color: color-mix(in srgb, var(--phase) 28%, transparent); }
[data-bs-theme="dark"] .session-progress .progress { background: #34465e; }
[data-bs-theme="dark"] .result-check { background: #173b2a; }
[data-bs-theme="dark"] .results-metrics strong { color: var(--green); }

@media (max-width: 767.98px) {
    .header-actions { gap: 10px; }
    .header-actions .header-label { display: none; }
}
@media (max-width: 359.98px) {
    .theme-label { display: none; }
    .theme-toggle { padding: 0 10px; }
}
