/* Breakpoints used across the app: 520 / 620 / 760 / 1000. Don't add a fifth without folding it into one of these. */

/* Inter (SIL Open Font License, fonts/Inter-LICENSE.txt), self-hosted so every device shows it, not only
   those with it installed. Variable weight 100–900; the extended-Latin file loads only for a page that
   uses those characters. Swap keeps text visible while a font downloads; the regular one is preloaded. */
@font-face {
    font-family: Inter;
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: Inter;
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: Inter;
    font-style: italic;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-wght-italic.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.dashboard-dialog { display: grid; gap: 14px; padding: 24px; }
.dashboard-dialog label { font-size: 14px; font-weight: 600; }
.dashboard-dialog input:not([type="range"]), .dashboard-dialog select, .dashboard-dialog textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; }
.dashboard-dialog input[type="range"] { width: 100%; accent-color: var(--accent); }
.dashboard-dialog p { margin: 0; font-size: 13px; color: var(--muted); }
.dashboard-dialog [role="alert"] { color: var(--danger); }
.dashboard-dialog .dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }

/* Theme. Every colour in the app is one of these tokens; scoped page styles never use a literal.
   theme-init.js sets <html data-theme="light|dark" data-accent="<preset>"> before first paint
   (System resolves to light or dark there), so this file needs no prefers-color-scheme query.
   Accent presets have a light and a dark value; the settings page lists the same names
   (Appearance/AppearanceOptions.cs), and theme-init.js reads the light value for the theme-color meta. */
:root {
    color-scheme: light;
    --preset-blue-l: #0b57e3;   --preset-blue-d: #6b9bff;
    --preset-indigo-l: #4f46e5; --preset-indigo-d: #8b93ff;
    --preset-violet-l: #7c3aed; --preset-violet-d: #b08cff;
    --preset-pink-l: #c0266d;   --preset-pink-d: #f47bb4;
    /* "red" is a deep crimson, not a true red, so an accent button never looks like a danger one
       (light #7f1d3a against danger #b52d3a, dark #ffb3ba against #f06a76: both clearly darker or lighter). */
    --preset-red-l: #7f1d3a;    --preset-red-d: #ffb3ba;
    --preset-orange-l: #c2410c; --preset-orange-d: #fb9a5b;
    --preset-teal-l: #0f766e;   --preset-teal-d: #3cd3c0;
    --preset-green-l: #177a3d;  --preset-green-d: #5ad58a;
    --preset-blue: var(--preset-blue-l);
    --preset-indigo: var(--preset-indigo-l);
    --preset-violet: var(--preset-violet-l);
    --preset-pink: var(--preset-pink-l);
    --preset-red: var(--preset-red-l);
    --preset-orange: var(--preset-orange-l);
    --preset-teal: var(--preset-teal-l);
    --preset-green: var(--preset-green-l);

    --ink: #0b1737;
    --muted: #63708a;
    --muted-light: #687285;
    --page: #fff;
    /* Paper is light whatever the theme: what a printed page uses. */
    --print-page: #fff;
    --print-ink: #111;
    --print-muted: #555;
    --print-rule: #ccc;
    --dashboard-page: #f3f6fb;
    --dashboard-muted: #5b6782;
    --dashboard-track: #eef2f8;
    --dashboard-soft: color-mix(in srgb, var(--accent) 8%, var(--surface));
    --dashboard-band: color-mix(in srgb, var(--success) 14%, var(--surface));
    --dashboard-chart: color-mix(in srgb, var(--accent) 16%, var(--surface));
    --surface: #fff;
    --surface-subtle: #f7f9fc;
    /* A QR code stays dark on light in both themes, or phone cameras miss it. */
    --qr-light: #fff;
    --qr-dark: #000;
    --border: #e5e9f1;
    /* Control outlines (inputs, secondary buttons): at least 3:1 on surface, surface-subtle and dashboard-page
       in both themes, the WCAG 1.4.11 floor for a control boundary. */
    --border-strong: #838da0;
    --accent: var(--preset-blue);
    --accent-hover: color-mix(in srgb, var(--accent) 86%, #000);
    --accent-soft: color-mix(in srgb, var(--accent) 7%, var(--surface));
    --accent-focus: color-mix(in srgb, var(--accent) 16%, transparent);
    --focus-ring: #174ba7;
    /* Text and icons on an accent, success, warning or danger fill. */
    --on-accent: #fff;
    /* Text on a --success or --warning fill: white on those is under 4.5:1. */
    --on-success: #0b1220;
    --on-warning: #0b1220;
    --success: #249b68;
    --success-strong: #16734c;
    --success-soft: #eaf8f1;
    --danger: #b52d3a;
    --danger-soft: #fff3f4;
    --danger-border: #f2bdc2;
    --warning: #d08a00;
    --warning-strong: #8a5a00;
    --warning-soft: #fff8e8;
    --warning-border: #f0d9a8;
    --scrim: rgba(11, 18, 32, .52);
    --shadow-color: #0b1220;
    --workout-card-highlight: rgba(255, 255, 255, .9);
    --workout-card-shadow:
        inset 0 1px 0 var(--workout-card-highlight),
        0 2px 0 color-mix(in srgb, var(--border-strong) 65%, transparent),
        0 7px 14px -5px color-mix(in srgb, var(--shadow-color) 24%, transparent),
        0 20px 36px -14px color-mix(in srgb, var(--shadow-color) 24%, transparent);
    /* Barcode camera: the frame behind the video, the aiming box and the dimming around it. */
    --camera-backdrop: #101828;
    --photo-marker: #fff;
    --photo-marker-shadow: #000;
    --photo-matte: #fff;
    --camera-guide: #fff;
    --camera-mask: rgba(0, 0, 0, .25);
    /* Kinds of training, as the workout history colours them, and the Stand ring. Fixed rather
       than the accent, so they stay apart whichever accent is chosen. */
    --activity-strength: var(--preset-blue);
    --activity-cardio: #e8590c;
    --activity-mindbody: #0e9384;
    --activity-stand: var(--hue-cyan);
    /* Data colours that do not follow the accent. */
    --chart-line: #0b57e3;
    --chart-line-2: #0f766e;
    --chart-area: #dce8ff;
    --chart-goal: #63708a;
    --chart-compare: #8d98ad;
    --heart: #ec5358;
    --zone-1: #6aa6e8;
    --zone-2: #3fb8a0;
    --zone-3: #8cc152;
    --zone-4: #f0a030;
    --zone-5: #ec5358;
    --star: #e5ad35;
    --chart-volume: #81cfc4;
    --chart-weight: #e77c9b;
    --chart-current: #e8b953;
    --hue-violet: #6247b5;
    --hue-cyan: #19a9ce;
    --hue-orange: #d77c30;
    --hue-gold: #aa7f20;
    --sleep-core: #7aa7ff;
    --sleep-deep: #1e3a8a;
    --sleep-rem: #2fa7c9;
    --sleep-other: #b9cdf5;
    --ecg-paper: #fff6f6;
    --ecg-grid-minor: #f6d3d3;
    --ecg-grid-major: #e8a3a3;
    --ecg-trace: #1a1f2e;
    --hearing-normal: #dff3e6;
    --hearing-mild: #fcf1c4;
    --hearing-moderate: #fbdfb8;
    --hearing-moderately-severe: #f8c9b6;
    --hearing-severe: #f1b4b4;
    --hearing-profound: #e4a9c6;
    --hearing-left: #0b57e3;
    --hearing-right: #c62828;
    --muscle-body: #f4f7fb;
    --muscle-other: #e1e8f2;
    --muscle-region: #d5e4f8;
    --muscle-selected: #ef6771;
    --muscle-outline: #353e82;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --chart-line: #6b9bff;
    --chart-line-2: #3cd3c0;
    --chart-area: #203352;
    --chart-goal: #9aa5ba;
    --chart-compare: #8190ab;
    --preset-blue: var(--preset-blue-d);
    --preset-indigo: var(--preset-indigo-d);
    --preset-violet: var(--preset-violet-d);
    --preset-pink: var(--preset-pink-d);
    --preset-red: var(--preset-red-d);
    --preset-orange: var(--preset-orange-d);
    --preset-teal: var(--preset-teal-d);
    --preset-green: var(--preset-green-d);

    --ink: #e7ecf5;
    --muted: #9aa5ba;
    --muted-light: #8590a6;
    --page: #0c111b;
    /* Paper is light whatever the theme: what a printed page uses. */
    --print-page: #fff;
    --print-ink: #111;
    --print-muted: #555;
    --print-rule: #ccc;
    --dashboard-page: #0c111b;
    --dashboard-muted: #9aa5ba;
    --dashboard-track: #1f2a3b;
    --dashboard-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
    --dashboard-band: color-mix(in srgb, var(--success) 18%, var(--surface));
    --surface: #141b28;
    --surface-subtle: #1b2433;
    --qr-light: #fff;
    --qr-dark: #000;
    --border: #263043;
    --border-strong: #626e88;
    --accent-hover: color-mix(in srgb, var(--accent) 84%, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--surface));
    --accent-focus: color-mix(in srgb, var(--accent) 32%, transparent);
    --focus-ring: #a9d1ff;
    /* Dark-theme fills are light, so the text on them is dark. */
    --on-accent: #0b1220;
    --on-success: #0b1220;
    --on-warning: #0b1220;
    --success: #3fbf86;
    --success-strong: #74d8a8;
    --success-soft: color-mix(in srgb, var(--success) 14%, var(--surface));
    --danger: #f06a76;
    --danger-soft: color-mix(in srgb, var(--danger) 14%, var(--surface));
    --danger-border: color-mix(in srgb, var(--danger) 42%, var(--surface));
    --warning: #e9a93a;
    --warning-strong: #f2c46d;
    --warning-soft: color-mix(in srgb, var(--warning) 14%, var(--surface));
    --warning-border: color-mix(in srgb, var(--warning) 42%, var(--surface));
    --scrim: rgba(0, 0, 0, .62);
    --shadow-color: #000;
    --workout-card-highlight: rgba(255, 255, 255, .08);
    --workout-card-shadow:
        inset 0 1px 0 var(--workout-card-highlight),
        0 2px 0 color-mix(in srgb, var(--shadow-color) 45%, transparent),
        0 8px 16px -5px color-mix(in srgb, var(--shadow-color) 55%, transparent),
        0 20px 36px -12px color-mix(in srgb, var(--shadow-color) 55%, transparent);
    --camera-backdrop: #000;
    /* Drawn over or into a photo, so unchanged by the theme. */
    --photo-marker: #fff;
    --photo-marker-shadow: #000;
    --photo-matte: #fff;
    --camera-guide: #e7ecf5;
    --camera-mask: rgba(0, 0, 0, .4);
    --activity-cardio: #fb7f3a;
    --activity-mindbody: #2cc4b1;
    --heart: #ff6b6b;
    --zone-1: #7db6f2;
    --zone-2: #52cdb4;
    --zone-3: #a0d468;
    --zone-4: #ffb44a;
    --zone-5: #ff6b6b;
    --chart-volume: #5fb8ad;
    --hue-violet: #a18cf0;
    --hue-cyan: #4cc7e6;
    --hue-orange: #f0a060;
    --hue-gold: #dcb24a;
    --sleep-deep: #4a67c9;
    --sleep-other: #8196c2;
    --sleep-rem: #5cc8e6;
    --ecg-paper: #261a1f;
    --ecg-grid-minor: #442a31;
    --ecg-grid-major: #744853;
    --ecg-trace: #f1f4fa;
    --hearing-normal: color-mix(in srgb, #3fbf86 24%, var(--surface));
    --hearing-mild: color-mix(in srgb, #e9c13a 22%, var(--surface));
    --hearing-moderate: color-mix(in srgb, #e9a93a 24%, var(--surface));
    --hearing-moderately-severe: color-mix(in srgb, #ee7f5a 26%, var(--surface));
    --hearing-severe: color-mix(in srgb, #f06a76 28%, var(--surface));
    --hearing-profound: color-mix(in srgb, #d46aa0 30%, var(--surface));
    --hearing-left: #6b9bff;
    --hearing-right: #ff8a80;
    --muscle-body: #1b2433;
    --muscle-other: #283246;
    --muscle-region: #2c3d5e;
    --muscle-selected: #f06a76;
    --muscle-outline: #7d89c9;
}

:root[data-accent="indigo"] { --accent: var(--preset-indigo); }
:root[data-accent="violet"] { --accent: var(--preset-violet); }
:root[data-accent="pink"] { --accent: var(--preset-pink); }
:root[data-accent="red"] { --accent: var(--preset-red); }
:root[data-accent="orange"] { --accent: var(--preset-orange); }
:root[data-accent="teal"] { --accent: var(--preset-teal); }
:root[data-accent="green"] { --accent: var(--preset-green); }

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

/* Settings › Appearance › Text size. Percentages keep the browser's own size setting as the base. */
html[data-text-size="small"] { font-size: 93.75%; }
html[data-text-size="large"] { font-size: 112.5%; }
html[data-text-size="larger"] { font-size: 125%; }

/* Low-pressure display (Settings, LowPressure.cs): a figure marked pressure-{token} is hidden while
   html[data-quiet] names the token, and its calm-{token} alternative is shown only then. */
.calm-streaks, .calm-scores, .calm-energy, .calm-weight { display: none !important; }
html[data-quiet~="streaks"] .pressure-streaks,
html[data-quiet~="scores"] .pressure-scores,
html[data-quiet~="energy"] .pressure-energy,
html[data-quiet~="weight"] .pressure-weight { display: none !important; }
html[data-quiet~="streaks"] .calm-streaks,
html[data-quiet~="scores"] .calm-scores,
html[data-quiet~="energy"] .calm-energy,
html[data-quiet~="weight"] .calm-weight { display: revert !important; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--page);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
    font-family: inherit;
}

/* iOS Safari zooms in on any field under 16px when it takes focus and never zooms back out,
   leaving the page wider than the screen. Scoped page styles set smaller sizes, hence
   !important; fields already larger (the set value editor) keep their own size. */
@media (hover: none) and (pointer: coarse) {
    input:not(.value-input), textarea, select {
        font-size: 16px !important;
    }
}

a, button {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

h1:focus {
    outline: none;
}

/* Every button's size. Pages that place a button adjust its layout, not its size. */
:root {
    --button-height: 36px;
    --button-padding: 13px;
    --button-font-size: .78rem;
    --button-radius: 8px;
}

.button {
    min-height: var(--button-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 var(--button-padding);
    border: 1px solid transparent;
    border-radius: var(--button-radius);
    font-size: var(--button-font-size);
    font-weight: 720;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.button[aria-busy="true"]:disabled,
.error-banner button[aria-busy="true"]:disabled {
    cursor: progress;
}

.button-primary {
    color: var(--on-accent);
    background: var(--accent);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 18%, transparent);
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.button-secondary {
    border-color: var(--border-strong);
    color: var(--ink);
    background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.icon-button {
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.icon-button:hover:not(:disabled) {
    color: var(--ink);
    background: var(--surface-subtle);
}

.icon-button:disabled {
    opacity: .3;
    cursor: default;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: absolute;
    left: 8px;
    top: -64px;
    z-index: 1000;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 8px;
}

main[tabindex="-1"]:focus {
    outline: none;
}

.validation-message {
    color: var(--danger);
    font-size: .75rem;
}

.invalid:not([type=checkbox]) {
    border-color: var(--danger) !important;
}

.route-loading {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.route-error {
    min-height: 100vh;
    max-width: 34rem;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
}

.route-error h1 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--ink);
}

.route-error p {
    margin: 0;
    color: var(--muted);
}

.route-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

#blazor-error-ui {
    position: fixed;
    z-index: 1000;
    right: 18px;
    bottom: 18px;
    display: none;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border: 1px solid var(--danger-border);
    border-radius: 10px;
    color: var(--danger);
    background: var(--danger-soft);
    box-shadow: 0 15px 40px color-mix(in srgb, var(--shadow-color) 14%, transparent);
    font-size: .82rem;
}

#blazor-error-ui .reload {
    color: inherit;
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    border: 0;
    color: inherit;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
}

.dialog-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--scrim);
    backdrop-filter: blur(3px);
}

.confirm-dialog,
.picker-dialog {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--shadow-color) 24%, transparent);
}

/* Kept off .picker-dialog: its header/search/list/footer children carry their own padding. */
.confirm-dialog {
    padding: 28px;
}

.confirm-dialog h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.28rem;
    letter-spacing: -.025em;
}

.confirm-dialog > p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: .88rem;
    line-height: 1.55;
}

.dialog-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 12px;
    font-weight: 800;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.state-panel {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.state-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    border-radius: 14px;
    color: var(--accent);
    background: var(--accent-soft);
    font-size: 1.4rem;
    font-weight: 800;
}

.state-panel h2,
.state-panel h3 {
    margin: 0;
    font-size: 1.08rem;
}

.state-panel p {
    margin: 8px 0 20px;
    color: var(--muted);
    font-size: .86rem;
}

.state-panel-compact {
    min-height: 0;
    padding: 24px 16px;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.state-panel-compact .state-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
}

.state-panel-compact p {
    margin-bottom: 12px;
}

.state-icon-error {
    color: var(--danger);
    background: var(--danger-soft);
}

.error-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 14px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--danger-border);
    border-radius: 10px;
    color: var(--ink);
    background: var(--danger-soft);
    font-size: .86rem;
}

.error-banner-text {
    flex: 1 1 200px;
    min-width: 0;
}

.error-banner button {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--ink);
    background: var(--surface);
    font: inherit;
    font-size: .8rem;
    font-weight: 650;
    cursor: pointer;
}

.error-banner button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.error-banner button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.error-banner button:focus-visible {
    outline: 3px solid var(--accent-focus);
    outline-offset: 2px;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    justify-self: start;
    max-width: 100%;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-subtle);
    box-shadow: inset 0 0 0 1px var(--border);
}

.segmented > button,
.segmented > label {
    position: relative;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    color: var(--muted);
    background: none;
    font: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
}

.segmented > button:hover:not(:disabled),
.segmented > label:hover {
    color: var(--ink);
}

.segmented > button[aria-checked="true"],
.segmented > button.selected,
.segmented > label.selected {
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow-color) 12%, transparent), 0 0 0 1px var(--border);
}

.segmented > button:disabled {
    opacity: .6;
    cursor: default;
}

.segmented > label input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.segmented > button:focus-visible,
.segmented > label:has(input:focus-visible) {
    outline: 3px solid var(--accent-focus);
    outline-offset: 2px;
}

.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.data-table td {
    color: var(--ink);
    font-size: .88rem;
    font-variant-numeric: tabular-nums;
}

.data-table tbody tr:nth-child(even) {
    background: var(--surface-subtle);
}

.data-table tbody tr.selected,
.data-table tbody tr.selected td {
    background: var(--accent-soft);
    font-weight: 650;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table .num {
    text-align: right;
}

.skeleton-row {
    min-height: 66px;
    display: grid;
    grid-template-columns: var(--skeleton-columns, 1fr 1fr 1fr);
    grid-auto-rows: 0;
    align-items: center;
    gap: 0 20px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 600px) {
    .skeleton-row {
        grid-template-columns: var(--skeleton-columns-phone, var(--skeleton-columns, 1fr 1fr 1fr));
    }
}

.skeleton-row span {
    height: 12px;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--border), var(--surface-subtle), var(--border));
    background-size: 220% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    to {
        background-position: -220% 0;
    }
}

.search-box {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    color: var(--muted);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-focus);
}

.search-box input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font: inherit;
    font-size: .86rem;
}

.badge,
.status,
.status-badge,
.added-badge,
.active-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    /* 12px at the default text size, so a badge can be read mid-set on a phone. */
    font-size: .75rem;
    font-weight: 720;
}

.injury-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.injury-chip {
    display: inline-flex;
    align-items: center;
    width: max-content;
    max-width: 100%;
    padding: 3px 8px;
    border: 1px solid var(--warning-border);
    border-radius: 999px;
    color: var(--warning-strong);
    background: var(--warning-soft);
    font-size: .75rem;
    font-weight: 720;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {
    .dialog-backdrop {
        align-items: end;
        padding: 12px;
    }

    .confirm-dialog {
        padding: 22px;
        border-radius: 16px 16px 12px 12px;
    }

    .dialog-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .dialog-actions .button {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-delay: -1ms !important;
        animation-iteration-count: 1 !important;
        /* Zero also avoids introducing a one-frame outline-color transition on custom controls. */
        transition-duration: 0s !important;
        transition-delay: 0s !important;
    }
}

/* Include native selects, summaries, SVG chart controls and custom tabindex controls.
   Scoped field styles may clear outlines for pointer focus; keyboard focus stays visible. */
:focus-visible,
input[type="date"]:focus-within,
input[type="time"]:focus-within,
input[type="datetime-local"]:focus-within {
    outline: 3px solid var(--focus-ring) !important;
    outline-offset: 3px;
}
@media (forced-colors: active) {
    :focus-visible { outline-color: Highlight !important; }
}

/* Native Tab scrolling must leave the focused control above the fixed phone navigation. */
@media (max-width: 760px) {
    html { scroll-padding-block: 12px calc(90px + env(safe-area-inset-bottom)); }
    :focus-visible, input[type="date"]:focus-within, input[type="time"]:focus-within,
    input[type="datetime-local"]:focus-within { scroll-margin-block: 12px calc(90px + env(safe-area-inset-bottom)); }
}
/* The workout's sticky save/finish bar is present on desktop too. */
html:has(.editor-shell) { scroll-padding-block: 12px 100px; }
body:has(.editor-shell) :focus-visible,
body:has(.editor-shell) input[type="date"]:focus-within,
body:has(.editor-shell) input[type="time"]:focus-within { scroll-margin-block: 12px 100px; }
@media (max-width: 760px) {
    html:has(.editor-shell) { scroll-padding-block-end: calc(180px + env(safe-area-inset-bottom)); }
}

/* The native nutrition form remains usable while a Server circuit reconnects. */
body:has(.nutrition-device-log[data-offline]) #components-reconnect-modal { display: none !important; }
/* Only a Server circuit: on WebAssembly the diary itself works with no signal. */
body:has(.nutrition-device-log[data-offline][data-circuit]) .nutrition-page > :not(.nutrition-device-log) { pointer-events: none; }

/* While the offline notice shows, it speaks for every read that could not load: the pages' own
   "couldn't load" warnings would only stack under it (and push a phone's editor down the screen).
   They come back with signal if the read still fails. Errors about something the athlete did stay. */
body:has(.offline-notice[data-offline]) .fold-offline { display: none !important; }

/* A workout under way has the phone screen to itself: the editor's dock takes the navigation bar's
   place, and "Leave for now" or the back link go elsewhere. */
@media (max-width: 760px) {
    body:has(.editor-shell.is-live) .mobile-nav { display: none; }
    body:has(.editor-shell.is-live) .app-shell { padding-bottom: 0; }
}

/* Printing (the routine print view): the app's chrome stays off the page, and so does anything marked no-print. */
@media print {
    /* Paper is white in either theme, so the page's own colours follow the print ones. */
    :root, :root[data-theme="dark"] {
        color-scheme: light;
        --ink: var(--print-ink);
        --muted: var(--print-muted);
        --muted-light: var(--print-muted);
        --page: var(--print-page);
        --surface: var(--print-page);
        --surface-subtle: var(--print-page);
        --border: var(--print-rule);
        --border-strong: var(--print-rule);
    }
    .sidebar, .mobile-nav, .skip-link, .update-banner, .no-print, #blazor-error-ui, .dialog-backdrop { display: none !important; }
    html, body, .app-shell, .app-content { background: var(--print-page) !important; color: var(--print-ink); }
    .app-shell { display: block; padding: 0; }
    .app-content { padding: 0; }
}

/* Pointer reordering (Components/SortableList, js/sortable-list.js): the copy that follows the
   pointer, the item being moved, and the bar with its new number where it will land. */
.sortable-ghost { position: fixed; z-index: 1000; max-height: 132px; overflow: hidden; border-radius: 14px; pointer-events: none; opacity: .96;
    box-shadow: 0 14px 32px -10px color-mix(in srgb, var(--shadow-color) 45%, transparent); }
.sortable-ghost > * { margin: 0; }
[data-sort-dragging] { opacity: .35; }
/* Above the copy, which is held right over the drop point. */
.sortable-marker { position: fixed; z-index: 1001; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft); pointer-events: none; }
.sortable-marker[hidden] { display: none; }
.sortable-marker span { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); padding: 3px 10px; border-radius: 999px;
    background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; line-height: 1.4; white-space: nowrap; }
html.sorting, html.sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
