/* ==========================================================================
   Formiam

   Parti pris : une fiche de cuisine typographique, proche d'un tableau de
   valeurs nutritionnelles. Une seule famille de caractères (Archivo,
   auto-hébergée), des filets plutôt que des cartes ombrées, des chiffres
   tabulaires. Deux rayons, une seule ombre (les dialogues).

   Couleur : un vert pour l'en-tête et les actions, un safran pour l'onglet
   ouvert, et une teinte par type de repas (--cat-*), reprise partout où ce
   repas apparaît. La couleur ne porte jamais seule l'information.

   CSP `default-src 'self'` : pas de style en ligne, pas de ressource externe.
   ========================================================================== */

@font-face {
    font-family: "Archivo";
    src: url("fonts/archivo-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: light dark;

    --bg: #fcfcfa;
    --surface: #ffffff;          /* champs, dialogues */
    --panel: #e9f2ea;            /* panneau de formulaire */
    --ink: #17191b;
    --ink-2: #565b54;            /* texte secondaire */
    --rule: #dcdcd4;             /* filets fins */
    --field-border: #8b8e85;     /* contour des champs (3:1 sur blanc) */
    --accent: #1d5a3c;           /* fond des actions principales */
    --accent-strong: #164a31;
    --on-accent: #ffffff;
    --link: #1d5a3c;             /* vert employé comme couleur de texte */
    --selected: #e4eee8;
    --danger: #b3261e;
    --danger-strong: #931d17;
    --on-danger: #ffffff;
    --backdrop: rgb(20 22 20 / 0.5);
    --mark: #f6e7a1;

    --header-bg: #1d5a3c;
    --header-ink: #ffffff;
    --header-ink-2: #c9ddd0;     /* onglet inactif, adresse du compte */
    --header-line: rgb(255 255 255 / 0.5);
    --marker: #f2b632;           /* safran : onglet ouvert */

    /* Une teinte par type de repas. Mêmes clés que CATEGORY_LABELS (app.js). */
    --cat-petit-dejeuner: #e3a008;
    --cat-dejeuner: #3d9a63;
    --cat-diner: #3f63b5;
    --cat-snack: #dc5a36;

    --font: "Archivo", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --r-control: 6px;
    --r-surface: 10px;
    --gutter: clamp(1rem, 4vw, 2.5rem);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141614;
        --surface: #1d201d;
        --panel: #1a231d;
        --ink: #ecece6;
        --ink-2: #a5a99f;
        --rule: #31352f;
        --field-border: #747970;
        --accent: #84caa2;
        --accent-strong: #9ad6b3;
        --on-accent: #0f1a13;
        --link: #84caa2;
        --selected: #1f2c24;
        --danger: #f08a82;
        --danger-strong: #f5a29b;
        --on-danger: #2a0b09;
        --backdrop: rgb(0 0 0 / 0.6);
        --mark: #5c5012;

        --header-bg: #17382a;
        --header-ink: #f1f1ec;
        --header-ink-2: #a9c2b3;
        --header-line: rgb(255 255 255 / 0.4);

        --cat-petit-dejeuner: #f0b83a;
        --cat-dejeuner: #6cc490;
        --cat-diner: #7f9fe6;
        --cat-snack: #f08260;
    }
}

*, *::before, *::after { box-sizing: border-box; }

/* Author `display` rules would otherwise win over the hidden attribute. */
[hidden] { display: none !important; }

/* Visitors browse the base catalogue read-only. */
body.guest .owner-only { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 400 1rem/1.5 var(--font);
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.2;
    text-wrap: balance;
}

a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

.num { font-variant-numeric: tabular-nums; }

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -4rem;
    z-index: 100;
    padding: 0.5rem 0.75rem;
    background: var(--ink);
    color: var(--bg);
    border-radius: var(--r-control);
}
.skip-link:focus { top: 0.5rem; }

/* ---------- En-tête ---------- */

/* Bandeau de couleur sur toute la largeur ; le contenu reste aligné sur la page. */
.site-header {
    background: var(--header-bg);
    color: var(--header-ink);
}
.site-header-inner {
    display: flex;
    align-items: flex-end;
    column-gap: 2.5rem;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 0;
}
.site-header :focus-visible { outline-color: var(--header-ink); }
.site-header button {
    color: var(--header-ink);
    border-color: var(--header-line);
}
.site-header button.quiet { border-color: transparent; }

.brand {
    flex: none;
    margin: 0;
    padding-bottom: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    font-stretch: 85%;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
}
.brand a { color: inherit; text-decoration: none; }

/* Onglets + compte. Sur grand écran, ce conteneur s'efface : ses deux enfants
   se rangent directement dans le bandeau. Sous 60rem, il devient le menu
   déroulant (voir plus bas). */
.site-menu { display: contents; }
.menu-toggle { display: none; }

.tabs { display: flex; flex: none; gap: 1.75rem; }
/* Un onglet est un bouton (sections de la page) ou un lien (autre page) :
   les deux doivent avoir exactement la même boîte. */
.tab {
    display: inline-flex;
    align-items: center;
    min-height: 0;
    padding: 0.5rem 0 0.5rem;
    border: 0;
    border-bottom: 4px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--header-ink-2);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
}
.site-header .tab {
    color: var(--header-ink-2);
    border-color: transparent;
}
.site-header .tab.active {
    color: var(--header-ink);
    font-weight: 650;
    border-bottom-color: var(--marker);
}

.auth-area {
    min-width: 0;
    margin-left: auto;
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.auth-area button { flex: none; }
/* L'adresse du compte : c'est elle qui cède la place quand le bandeau est plein. */
.auth-area .user-name {
    min-width: 0;
    max-width: 16rem;
    margin-right: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9375rem;
    color: var(--header-ink-2);
}

/* Juste au-dessus de 60rem, les cinq onglets et le compte ne tiennent sur la
   ligne qu'en se serrant : espaces réduits, et l'adresse du compte (visible
   dans « Mon compte ») laisse sa place. */
@media (min-width: 60rem) and (max-width: 67.99rem) {
    .site-header-inner { column-gap: 1.5rem; }
    .brand { font-size: 1.375rem; }
    .tabs { gap: 1.125rem; }
    .tab { font-size: 0.9375rem; }
    .auth-area .user-name { display: none; }
    .auth-area button { padding-inline: 0.5rem; }
}

/* Trois barres, qui se croisent quand le menu est ouvert. */
.menu-icon, .menu-icon::before, .menu-icon::after {
    display: block;
    width: 1.25rem;
    height: 2px;
    background: currentColor;
}
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
    transition: transform 150ms var(--ease-out);
}
.menu-icon::before { transform: translateY(-6px); }
.menu-icon::after { transform: translateY(6px); }
.menu-toggle[aria-expanded="true"] .menu-icon { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-icon::before { transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon::after { transform: rotate(-45deg); }

/* Téléphone et tablette : une seule ligne (nom du site, bouton « Menu ») qui
   reste en haut de l'écran ; les onglets et le compte se déplient dessous. */
@media (max-width: 59.99rem) {
    /* Ce que le script fait défiler à l'écran s'arrête sous le bandeau. */
    html { scroll-padding-top: 4.5rem; }

    .site-header { position: sticky; top: 0; z-index: 50; }
    .site-header-inner {
        align-items: center;
        justify-content: space-between;
        column-gap: 1rem;
        padding-block: 0.5rem;
    }
    .brand { padding-bottom: 0; font-size: 1.3125rem; }

    .menu-toggle {
        display: inline-flex;
        gap: 0.625rem;
        min-height: 2.75rem;
        margin-right: -0.625rem;   /* le libellé s'aligne sur la marge de la page */
        font-size: 1rem;
    }

    .site-menu {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1;
        max-height: calc(100dvh - 100%);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0.5rem var(--gutter) 1.25rem;
        background: var(--header-bg);
        border-top: 1px solid var(--header-line);

        /* Fermé : invisible et hors de portée du clavier. */
        visibility: hidden;
        opacity: 0;
        transform: translateY(-0.375rem);
        transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out),
                    visibility 0s 120ms;
    }
    .site-header.is-open .site-menu {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
    }
    /* Le reste de la page s'assombrit ; un appui dessus referme le menu. */
    .site-header.is-open::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 100dvh;
        background: var(--backdrop);
        animation: fade 180ms ease;
    }

    .site-menu .tabs { flex-direction: column; gap: 0; }
    .site-menu .tab {
        justify-content: flex-start;
        min-height: 3rem;
        padding: 0;
        border-bottom: 0;
        font-size: 1.0625rem;
    }
    /* Le trait safran passe sous le mot : la ligne entière reste la zone d'appui. */
    .site-menu .tab.active {
        text-decoration: underline 3px var(--marker);
        text-underline-offset: 0.4em;
    }

    .site-menu .auth-area {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin: 0.5rem 0 0;
        padding: 0.5rem 0 0;
        border-top: 1px solid var(--header-line);
    }
    .site-menu .user-name {
        max-width: none;
        margin: 0;
        padding: 0.625rem 0 0.25rem;
    }
    .site-menu .auth-area button {
        justify-content: flex-start;
        min-height: 3rem;
        padding: 0;
        font-size: 1.0625rem;
    }
    /* « Créer un compte » garde son contour et prend toute la largeur. */
    .site-menu .auth-area button:not(.quiet) {
        justify-content: center;
        margin-top: 0.5rem;
        font-weight: 600;
    }

    /* Page de texte : un seul lien, qui reste dans la ligne. */
    .site-header-inner > .tabs .tab { padding-block: 0.75rem; border-bottom: 0; }
}

/* ---------- Structure ---------- */

main {
    flex: 1;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2rem var(--gutter) 4rem;
}
@media (max-width: 40rem) {
    main { padding-top: 1.5rem; }
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.layout {
    display: grid;
    gap: 2rem;
}
.layout > * { min-width: 0; }

@media (min-width: 60rem) {
    .layout {
        grid-template-columns: 22.5rem minmax(0, 1fr);
        gap: 3.5rem;
        align-items: start;
    }
    .narrow-only { display: none !important; }
}
/* Le panneau ne reste collé que s'il tient en entier dans la fenêtre. */
@media (min-width: 60rem) and (min-height: 54rem) {
    .side { position: sticky; top: 1.5rem; }
}
@media (max-width: 59.99rem) {
    /* Sur petit écran, le formulaire d'ajout se déplie à la demande. */
    #dish-panel:not(.is-open) #dish-form-region { display: none; }
    #toggle-form { width: 100%; }
    #dish-panel.is-open #toggle-form { margin-bottom: 1rem; }
}

.panel {
    padding: 1.5rem;
    background: var(--panel);
    border-radius: var(--r-surface);
}
@media (max-width: 40rem) {
    .panel { padding: 1.25rem; }
}

.section-title {
    font-size: 1.375rem;
    font-weight: 700;
    font-stretch: 90%;
    letter-spacing: -0.01em;
}
.panel .section-title { margin-bottom: 1.25rem; }

/* Grand titre : présentation du site aux visiteurs, titre d'une page */
.intro h2, .page-title {
    font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2rem);
    font-weight: 750;
    font-stretch: 88%;
    letter-spacing: -0.015em;
    line-height: 1.1;
}
.intro p { margin: 1rem 0 0; max-width: 34rem; }
.intro .small { font-size: 0.875rem; color: var(--ink-2); }
.intro .actions { margin-top: 1.5rem; }

/* ---------- Boutons ---------- */

button, a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid var(--field-border);
    border-radius: var(--r-control);
    background: transparent;
    color: var(--ink);
    font: 500 0.9375rem/1.2 var(--font);
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 150ms ease, border-color 150ms ease,
                color 150ms ease, transform 120ms var(--ease-out);
}
button:active:not(:disabled), a.button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button[aria-busy="true"] { cursor: progress; }

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}
button.danger-solid {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-danger);
    font-weight: 600;
}
button.quiet { border-color: transparent; padding: 0 0.625rem; }

button.link {
    min-height: 1.5rem;
    padding: 0;
    border: 0;
    border-radius: 2px;
    background: none;
    color: var(--link);
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
}
button.link.danger { color: var(--danger); }
button.link:active:not(:disabled), .tab:active:not(:disabled) { transform: none; }

@media (hover: hover) and (pointer: fine) {
    button:hover:not(:disabled), a.button:hover {
        background: color-mix(in srgb, var(--ink) 7%, transparent);
    }
    button.primary:hover:not(:disabled) {
        background: var(--accent-strong);
        border-color: var(--accent-strong);
    }
    button.danger-solid:hover:not(:disabled) {
        background: var(--danger-strong);
        border-color: var(--danger-strong);
    }
    button.link:hover:not(:disabled) { background: none; text-decoration-thickness: 2px; }
    .site-header button:hover:not(:disabled) {
        background: color-mix(in srgb, var(--header-ink) 14%, transparent);
    }
    .site-header .tab:hover:not(:disabled) { background: none; color: var(--header-ink); }
}
/* Écran tactile : 44px au moins pour tout ce qui se touche du doigt. */
@media (pointer: coarse) {
    button, a.button, button.link { min-height: 2.75rem; }
    .tab { min-height: 0; padding-block: 0.75rem; }
    .check { min-height: 2.75rem; }
    input[type="checkbox"] { width: 1.375rem; height: 1.375rem; }
    summary { padding-block: 0.75rem; }
    .prep-limit input, .macro-table input { min-height: 2.75rem; }
    .dish .select-box { width: 1.5rem; height: 1.5rem; margin-top: 0; }
    .dish-actions { gap: 1.75rem; margin-top: 0.125rem; }
    .site-footer a { display: inline-block; padding-block: 0.75rem; }
    .site-footer p { padding-top: 0.25rem; }
}

:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }

/* ---------- Formulaires ---------- */

.field {
    display: block;
    margin: 0 0 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
    display: block;
    width: 100%;
    min-height: 2.5rem;
    margin-top: 0.375rem;
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--field-border);
    border-radius: var(--r-control);
    background: var(--surface);
    color: var(--ink);
    font: 400 1rem/1.4 var(--font);
    font-variant-numeric: tabular-nums;
    transition: border-color 150ms ease;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 0.75; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 1px;
    border-color: var(--link);
}
/* Liste déroulante et date : flèche et calendrier natifs, mêmes contour, fond
   et hauteur que les autres champs. La date n'a pas l'apparence native : sur
   iPhone, Safari impose alors à ce champ une largeur minimale (la date la plus
   longue) et box-sizing: content-box, et il dépassait de son conteneur de ses
   marges intérieures et de son contour. Le calendrier s'ouvre toujours. */
select { cursor: pointer; text-overflow: ellipsis; }
input[type="date"] { min-width: 0; -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input:disabled { opacity: 0.4; cursor: not-allowed; }

input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex: none;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Les cases « type de repas » prennent la teinte du repas une fois cochées. */
input[name="categories"][value="petit-dejeuner"] { accent-color: var(--cat-petit-dejeuner); }
input[name="categories"][value="dejeuner"] { accent-color: var(--cat-dejeuner); }
input[name="categories"][value="diner"] { accent-color: var(--cat-diner); }
input[name="categories"][value="snack"] { accent-color: var(--cat-snack); }

/* Type de repas : pastille carrée de couleur + libellé */
.cat { white-space: nowrap; }
.cat::before {
    content: "";
    display: inline-block;
    width: 0.5625rem;
    height: 0.5625rem;
    margin-right: 0.375rem;
    border-radius: 2px;
    background: var(--cat-color, var(--ink-2));
}
.cat + .cat { margin-left: 0.625rem; }
.cat-petit-dejeuner { --cat-color: var(--cat-petit-dejeuner); }
.cat-dejeuner { --cat-color: var(--cat-dejeuner); }
.cat-diner { --cat-color: var(--cat-diner); }
.cat-snack { --cat-color: var(--cat-snack); }

.check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2rem;
    font-size: 0.9375rem;
    cursor: pointer;
}

fieldset {
    margin: 0 0 1.25rem;
    padding: 0;
    border: 0;
    min-width: 0;
}
legend {
    padding: 0;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}
/* Titre de groupe dans le formulaire du générateur */
legend.group {
    width: 100%;
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--field-border);
    font-size: 0.9375rem;
    font-weight: 700;
}

.cols-2, .cols-3 { display: grid; gap: 0 0.75rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
/* Deux colonnes seulement quand la place le permet (dates, listes déroulantes). */
.field-grid { display: grid; gap: 0 0.75rem; }
@media (min-width: 36rem) {
    .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
}

.hint {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.field + .hint { margin-top: -0.625rem; }
.check + .hint { margin-top: -0.125rem; }
.hint.notice {
    margin-top: 1rem;
    padding: 0.75rem 0.875rem;
    background: var(--panel);
    border-radius: var(--r-control);
}

.error, .success {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    font-weight: 500;
}
.error { color: var(--danger); }
.success { color: var(--link); }
.error:empty, .success:empty { display: none; }

/* Repas à inclure : une ligne par repas, limite de préparation à droite */
.meal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.25rem 0;
}
.prep-limit {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--ink-2);
    white-space: nowrap;
}
.prep-limit input {
    width: 3.75rem;
    min-height: 2rem;
    margin: 0;
    padding: 0.125rem 0.375rem;
    text-align: center;
    font-size: 0.9375rem;
}

details { margin: 0 0 1.25rem; }
summary {
    padding: 0.375rem 0;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 2px;
}
.macro-table {
    width: 100%;
    margin-top: 0.5rem;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.macro-table th { font-weight: 500; color: var(--ink-2); }
.macro-table thead th { padding: 0 0.25rem 0.375rem; }
.macro-table tbody th { padding-right: 0.5rem; text-align: left; white-space: nowrap; }
.macro-table td { padding: 0.25rem; }
.macro-table input {
    margin: 0;
    min-height: 2.125rem;
    padding: 0.125rem 0.25rem;
    text-align: center;
    font-size: 0.9375rem;
}

/* ---------- Liste des plats ---------- */

.list-head {
    display: flex;
    align-items: baseline;
    gap: 0.625rem;
    margin-bottom: 1rem;
}
.list-head .count { color: var(--ink-2); font-size: 0.9375rem; }

#dish-search { margin-top: 0; }

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.list-toolbar button { min-height: 2.25rem; font-size: 0.875rem; padding: 0 0.75rem; }
@media (pointer: coarse) { .list-toolbar button { min-height: 2.75rem; } }

#import-result { margin: 0.75rem 0 0; font-size: 0.875rem; }
#import-result:empty { display: none; }

.dish-list {
    margin-top: 1.25rem;
    border-top: 2px solid var(--ink);
}
.dish {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 0.875rem;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--rule);
}
.dish.selected { background: var(--selected); }
.dish .select-box { margin-top: 0.1875rem; }
.dish h3 { font-size: 1.0625rem; font-weight: 650; line-height: 1.3; }
.dish p { margin: 0; }
.dish-meta { margin-top: 0.125rem; font-size: 0.8125rem; color: var(--ink-2); }
.dish-ingredients { margin-top: 0.5rem !important; font-size: 0.9375rem; max-width: 34rem; }
.dish-kcal {
    text-align: right;
    white-space: nowrap;
    font-size: 1.125rem;
    font-weight: 700;
    font-stretch: 90%;
    line-height: 1.3;
}
.unit { font-size: 0.8125rem; font-weight: 400; font-stretch: 100%; color: var(--ink-2); }

/* Valeurs nutritionnelles : libellé discret, valeur en clair */
.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem 1.25rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.dish-actions { display: flex; gap: 1.25rem; margin-top: 0.5rem; font-size: 0.875rem; }

/* Téléphone : seuls le nom et les calories se partagent la première ligne ;
   le reste du plat prend toute la largeur, sous le nom. */
@media (max-width: 36rem) {
    .dish { padding-inline: 0.25rem; }
    .dish > div { display: contents; }
    .dish .select-box { grid-area: 1 / 1; }
    .dish h3 { grid-area: 1 / 2; }
    .dish-kcal { grid-area: 1 / 3; }
    .dish > div > :not(h3) { grid-column: 2 / -1; }
    .facts { column-gap: 1rem; }
}

.empty {
    margin: 0;
    padding: 2.5rem 0;
    color: var(--ink-2);
    max-width: 30rem;
}

/* ---------- Résultats du générateur ---------- */

#gen-results { transition: opacity 150ms ease; }
#gen-results.is-stale { opacity: 0.5; }

.results-summary {
    margin: 0 0 1.5rem;
    font-size: 0.9375rem;
    color: var(--ink-2);
}
.results-summary strong { color: var(--ink); font-weight: 650; }

.notice {
    margin: 0;
    padding: 0.875rem 1rem;
    background: var(--panel);
    border-radius: var(--r-control);
}
/* Dans un panneau, déjà de cette couleur, l'encart passe sur le fond des champs. */
.panel .notice { background: var(--surface); }

.combo {
    margin-bottom: 2.25rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--ink);
    animation: rise 260ms var(--ease-out) backwards;
}
.combo:nth-of-type(2) { animation-delay: 40ms; }
.combo:nth-of-type(3) { animation-delay: 80ms; }
.combo:nth-of-type(4) { animation-delay: 120ms; }
.combo:nth-of-type(n+5) { animation-delay: 160ms; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }

.combo-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.combo-head h3 { font-size: 1.0625rem; font-weight: 700; padding-top: 0.25rem; }
.combo-total { margin: 0; text-align: right; }
.combo-kcal {
    display: block;
    font-size: 1.375rem;
    font-weight: 750;
    font-stretch: 90%;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--link);
}
.combo-kcal .unit { color: inherit; }
.combo-delta { display: block; font-size: 0.8125rem; color: var(--ink-2); }

.combo ul.slots { list-style: none; margin: 0; padding: 0; }
.slots li {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr) 5.25rem 3.75rem;
    column-gap: 1rem;
    align-items: baseline;
    padding: 0.5rem 0;
    border-top: 1px solid var(--rule);
    font-size: 0.9375rem;
}
.slot-label { font-size: 0.8125rem; color: var(--ink-2); }
.slot-name { font-weight: 500; }
.slot-kcal, .slot-time { text-align: right; white-space: nowrap; }
.slot-time { color: var(--ink-2); font-size: 0.8125rem; }
@media (max-width: 36rem) {
    .slots li { grid-template-columns: minmax(0, 1fr) 5.25rem 3.75rem; }
    .slot-label { grid-column: 1 / -1; }
}
.combo .facts {
    margin: 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--field-border);
    font-size: 0.875rem;
}

/* ---------- Dialogues ---------- */

dialog {
    width: min(28rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.75rem;
    border: 1px solid var(--rule);
    border-radius: var(--r-surface);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.35);

    /* Sortie (plus rapide que l'entrée) */
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out),
                overlay 150ms allow-discrete, display 150ms allow-discrete;
}
dialog[open] {
    opacity: 1;
    transform: none;
    transition-duration: 220ms;
}
@starting-style {
    dialog[open] { opacity: 0; transform: scale(0.97); }
}
dialog::backdrop {
    background: transparent;
    transition: background-color 150ms ease,
                overlay 150ms allow-discrete, display 150ms allow-discrete;
}
dialog[open]::backdrop { background: var(--backdrop); transition-duration: 220ms; }
@starting-style {
    dialog[open]::backdrop { background: transparent; }
}

dialog h2 {
    margin-bottom: 1.25rem;
    font-size: 1.375rem;
    font-weight: 700;
    font-stretch: 90%;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}
dialog h3 {
    margin: 1.5rem 0 0.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-size: 1rem;
    font-weight: 700;
}
dialog .field input, dialog .field select { background: var(--bg); }
/* Titre et bouton « Fermer » sur une ligne, pour un dialogue long. */
.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.dialog-head h2 { margin: 0; }
.dialog-head button { flex: none; margin-right: -0.625rem; }
.account-id strong { overflow-wrap: anywhere; }
.switch { margin: 1.25rem 0 0; font-size: 0.875rem; color: var(--ink-2); }
.dialog-footer {
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}

/* Téléphone : le dialogue monte du bas de l'écran et en prend toute la largeur,
   les boutons restent sous le pouce. */
@media (max-width: 40rem) {
    dialog {
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - 1.5rem);
        margin: auto 0 0;
        padding: 1.5rem var(--gutter) calc(1.5rem + env(safe-area-inset-bottom));
        border-width: 1px 0 0;
        border-radius: var(--r-surface) var(--r-surface) 0 0;
        overscroll-behavior: contain;
        transform: translateY(1.5rem);
    }
    @starting-style {
        dialog[open] { transform: translateY(1.5rem); }
    }
    dialog .actions > button { flex: 1 1 auto; }
}

/* ---------- Suivi du poids ---------- */

.lead { margin: 0 0 1.5rem; max-width: 34rem; }

/* Profil */
.profile { max-width: 40rem; }
.profile .page-title { margin-bottom: 1rem; }
/* Case dont le libellé tient sur plusieurs lignes (accords, options du compte). */
.check.consent { display: flex; align-items: flex-start; margin-bottom: 0.375rem; }
.check.consent input { margin-top: 0.1875rem; }
@media (pointer: coarse) {
    .check.consent { padding-block: 0.5rem; margin-bottom: 0; }
    .check.consent input { margin-top: 0; }
}
#target-warning { margin-top: 0; }
.erase {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
}
.erase h2 { margin-bottom: 0.375rem; font-size: 1rem; font-weight: 700; }
.erase .hint { margin-bottom: 0.5rem; }

/* Écran de suivi : résumé, courbe et pesées à gauche, calories à droite.
   Sur une colonne, l'ordre du code s'applique : résumé, calories, courbe, pesées. */
.tracker-head { justify-content: space-between; margin-bottom: 1.5rem; }
.tracker-head .link { flex: none; font-size: 0.9375rem; }

.tracker { display: grid; gap: 2.25rem; }
.tracker > * { min-width: 0; }
.tracker .section-title { margin-bottom: 1rem; }
.tracker .list-head .section-title { margin-bottom: 0; }
@media (min-width: 60rem) {
    .tracker {
        grid-template-columns: minmax(0, 1fr) 22.5rem;
        column-gap: 3.5rem;
        row-gap: 2.75rem;
        align-items: start;
    }
    .tracker > * { grid-column: 1; }
    .tracker > .tracker-side { grid-column: 2; grid-row: 1 / span 3; }
}

/* Départ, actuel, objectif */
.milestones {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 0.75rem;
    padding: 1.25rem 0 1.5rem;
    border-top: 2px solid var(--ink);
}
.milestone p { margin: 0; }
.milestone.is-current { text-align: center; }
.milestone:last-child { text-align: right; }
.milestone-label { font-size: 0.875rem; font-weight: 500; color: var(--ink-2); }
.milestone-value {
    font-size: clamp(1.375rem, 1.05rem + 1.4vw, 1.75rem);
    font-weight: 700;
    font-stretch: 90%;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
}
.is-current .milestone-value {
    font-size: clamp(2.5rem, 1.5rem + 4.4vw, 3.75rem);
    font-weight: 800;
    font-stretch: 85%;
    letter-spacing: -0.02em;
    line-height: 1.05;
}
.is-current .unit { font-size: 1rem; }
.milestone-date { font-size: 0.8125rem; color: var(--ink-2); }

/* Déjà perdu, reste, écart avec la courbe */
.progress {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 1.5rem;
    margin: 0;
    padding: 0.875rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--field-border);
}
.progress dt { font-size: 0.8125rem; color: var(--ink-2); }
.progress dd { margin: 0; }
.progress b {
    display: block;
    font-size: 1.125rem;
    font-weight: 700;
    font-stretch: 90%;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}
.progress span { display: block; font-size: 0.8125rem; color: var(--ink-2); }
@media (max-width: 36rem) {
    .progress { grid-template-columns: minmax(0, 1fr); padding: 0; }
    .progress > div { padding: 0.75rem 0; }
    .progress > div + div { border-top: 1px solid var(--rule); }
}

/* Calories du jour */
.kcal-target {
    margin: 0;
    font-size: 2.25rem;
    font-weight: 750;
    font-stretch: 88%;
    letter-spacing: -0.015em;
    line-height: 1.1;
    white-space: nowrap;
    color: var(--link);
}
.kcal-target .unit { font-size: 1rem; color: inherit; }
.kcal-caption { margin: 0.375rem 0 0; font-size: 0.9375rem; }
.tracker-side .hint.notice { margin-bottom: 0; }
.tracker-side .facts, .jr-side .facts {
    display: block;
    margin-top: 1rem;
    border-top: 1px solid var(--field-border);
    font-size: 0.875rem;
}
.tracker-side .facts li, .jr-side .facts li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--rule);
}
.tracker-side .actions > * { flex: 1 1 100%; }
.method { margin: 1.25rem 0 0; }
.method p { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--ink-2); }
.method strong { color: var(--ink); font-weight: 600; }

/* Courbe. Le SVG est produit par suivi.js ; ses couleurs viennent d'ici. */
.chart { min-height: 15rem; }
.chart svg {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 2px;
    touch-action: pan-y;
}
.chart text {
    font-family: var(--font);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    fill: var(--ink-2);
}
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-plan {
    fill: none;
    stroke: var(--ink-2);
    stroke-width: 1.5;
    stroke-dasharray: 5 5;
}
.chart-goal { fill: var(--bg); stroke: var(--ink-2); stroke-width: 1.5; }
.chart-line {
    fill: none;
    stroke: var(--link);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.chart-dot, .chart-focus { fill: var(--link); stroke: var(--bg); stroke-width: 2; }
.chart text.chart-label {
    fill: var(--ink);
    font-weight: 650;
    paint-order: stroke;
    stroke: var(--bg);
    stroke-width: 4px;
    stroke-linejoin: round;
}
.chart-cross { stroke: var(--field-border); stroke-width: 1; }
.chart-tip { pointer-events: none; }
.chart-tip rect { fill: var(--surface); stroke: var(--field-border); stroke-width: 1; }
.chart text.tip-value { fill: var(--ink); font-size: 0.9375rem; font-weight: 700; }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.chart-legend .key {
    display: inline-block;
    width: 1.5rem;
    margin-right: 0.5rem;
    vertical-align: middle;
    border-top: 2px solid var(--link);
}
.chart-legend .key-plan { border-top: 2px dashed var(--ink-2); }

/* Tableau de valeurs (pesées) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    border-top: 2px solid var(--ink);
    font-size: 0.9375rem;
}
.data-table th, .data-table td {
    padding: 0.5rem 0.75rem 0.5rem 0;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    font-weight: 400;
}
.data-table thead th { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.data-table tbody th { font-weight: 500; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table tr > :last-child {
    padding-right: 0;
    text-align: right;
    font-size: 0.875rem;
    color: var(--ink-2);
}
.history-hint { margin: 0.75rem 0 0; }
/* Écran tactile : le bouton de la ligne fait déjà 44px, la marge se réduit. */
@media (pointer: coarse) {
    .data-table tbody th, .data-table tbody td { height: 3rem; padding-block: 0.125rem; }
}

/* ---------- Musculation ----------
   Classes propres à la page, toutes préfixées mu- ; le reste vient des
   composants communs (.panel, .field, .data-table, .progress, .notice…).
   Les écrans sont construits par musculation.js. */

/* Accueil de la page : programmes à gauche, réglages de la séance à droite.
   Sur une colonne, l'ordre du code s'applique : programmes, réglages, historique. */
.mu-home { display: grid; gap: 2.25rem; }
.mu-home > * { min-width: 0; }
.mu-home .lead { margin: 0.75rem 0 0; }
.mu-home-side .section-title { margin-bottom: 1.25rem; }
.mu-home-side .actions { margin: 0 0 1rem; }
.mu-home-side .check.consent { margin-bottom: 0.5rem; }
.mu-home-side .hint.notice { margin-top: 0; }
.mu-home-history .list-head { margin-bottom: 1rem; }
@media (min-width: 60rem) {
    .mu-home {
        grid-template-columns: minmax(0, 1fr) 22.5rem;
        /* La dernière rangée, vide, absorbe la hauteur du panneau de droite quand
           il dépasse la colonne de gauche : celle-ci ne s'espace pas. */
        grid-template-rows: auto auto auto auto 1fr;
        column-gap: 3.5rem;
        row-gap: 2.75rem;
        align-items: start;
    }
    .mu-home > * { grid-column: 1; }
    .mu-home > .mu-home-head { grid-column: 1 / -1; }
    .mu-home > .mu-home-side { grid-column: 2; grid-row: 2 / -1; }
}

/* État de l'enregistrement dans le compte */
.mu-sync { margin: 0; }
.mu-sync .error { margin: 0; }

/* Séance en cours sur cet appareil */
.mu-encours { margin-top: 1.25rem; max-width: 42rem; }
.mu-encours p { margin: 0; }
.mu-encours .actions { align-items: center; margin-top: 0.75rem; font-size: 0.9375rem; }

/* Un programme : filet fort, puis une ligne par séance */
.mu-progs { margin-top: 1.25rem; }
.mu-prog { padding: 0.875rem 0 1.5rem; border-top: 2px solid var(--ink); }
.mu-prog h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.mu-prog p { margin: 0; }
.mu-prog .mu-prog-note {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    max-width: 34rem;
    margin-top: 0.5rem;
    font-size: 0.9375rem;
    white-space: pre-line;
}
.mu-sessions { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.mu-sessions li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--rule);
}
.mu-sessions li > div { display: grid; min-width: 0; }
.mu-sessions .slot-name { overflow-wrap: anywhere; }
.mu-sessions button { flex: none; }
.mu-prog .dish-actions {
    margin-top: 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--field-border);
}
.mu-prog > .actions { align-items: center; margin-top: 0; padding-top: 0.75rem; border-top: 1px solid var(--field-border); font-size: 0.9375rem; }

/* Liste de choix (assistant, classiques, bibliothèque d'exercices) : une ligne
   par choix, le nom puis une précision. */
.mu-choices {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    border-top: 2px solid var(--ink);
}
.mu-choices li { border-bottom: 1px solid var(--rule); }
.mu-choices li.hint { margin: 0; padding: 0.75rem 0.5rem; }
button.mu-choice {
    display: grid;
    justify-content: stretch;
    justify-items: start;
    gap: 0.125rem;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.625rem 0.5rem;
    border: 0;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
}
button.mu-choice:active:not(:disabled) { transform: none; }
.mu-choice strong { font-weight: 650; overflow-wrap: anywhere; }
.mu-choice span { font-size: 0.8125rem; color: var(--ink-2); }
button.mu-choice[aria-pressed="true"] { background: var(--selected); }

/* Nouveau programme, assistant, éditeur, historique : une colonne de lecture */
.mu-narrow, .mu-edit, .mu-history { max-width: 44rem; }
.mu-back { margin: 0 0 1rem; font-size: 0.9375rem; }
.mu-narrow .page-title, .mu-edit .page-title, .mu-history .page-title { margin-bottom: 1rem; }
.mu-narrow .page-title:focus { outline: none; }
.mu-step-count { margin-bottom: 0.5rem; }
.mu-way { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.mu-way .section-title { margin-bottom: 0.5rem; }
.mu-way p { margin: 0; max-width: 34rem; }

/* Proposition de l'assistant */
.mu-preview { display: grid; gap: 0 2.5rem; }
@media (min-width: 36rem) {
    .mu-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.mu-preview section { padding: 0.75rem 0 1.25rem; border-top: 2px solid var(--ink); }
.mu-preview h2 { font-size: 1.0625rem; font-weight: 700; }
.mu-preview p { margin: 0; }
.mu-preview ol { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.mu-preview li {
    display: grid;
    padding: 0.375rem 0;
    border-top: 1px solid var(--rule);
    font-size: 0.9375rem;
}

/* Éditeur d'un programme : une séance par bloc, un exercice par ligne */
.mu-edit .panel { margin-bottom: 1.5rem; }
.mu-edit .panel > .hint { margin-bottom: 0.25rem; }
.mu-toc {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    color: var(--ink-2);
}
.mu-seance {
    margin-bottom: 2.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--ink);
    scroll-margin-top: 1rem;
}
.mu-seance-nom input { font-size: 1.125rem; font-weight: 650; }
.mu-seance > .dish-meta { margin: -0.5rem 0 0; }
.mu-seance .empty { padding: 1rem 0 0; }
.mu-seance > .actions { margin-top: 1rem; }
.mu-seance > .dish-actions { flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.75rem; }
.mu-exos {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    border-top: 1px solid var(--field-border);
}
.mu-exo { padding: 1rem 0 0.875rem; border-bottom: 1px solid var(--rule); }
.mu-exo .field { margin-bottom: 0.75rem; }
.mu-exo-nom input { font-weight: 600; }
/* Séries, répétitions, charge, repos : quatre cases sur une ligne, même sur téléphone */
.mu-fields, .mu-set-fields {
    display: grid;
    gap: 0 0.5rem;
    align-items: end;
    max-width: 30rem;
}
.mu-fields { grid-template-columns: 4.5rem repeat(3, minmax(0, 1fr)); }
.mu-set-fields { grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); }
.mu-fields input, .mu-set-fields input { padding-inline: 0.25rem; text-align: center; }
.mu-fields .error:not(:empty) { display: block; margin-top: 0.25rem; font-size: 0.8125rem; font-weight: 400; }
.mu-exo-note, .mu-lie { margin-bottom: 0.5rem; }
.mu-exo-note { white-space: pre-line; overflow-wrap: anywhere; }
.mu-lie { font-weight: 500; color: var(--ink); }
.mu-exo > .dish-actions { margin-top: 0; }
.mu-options {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--panel);
    border-radius: var(--r-surface);
}
.mu-options .actions { align-items: center; margin-top: 0.75rem; }
.mu-sets ol { list-style: none; margin: 0; padding: 0; }
.mu-sets li { padding-top: 0.5rem; border-top: 1px solid var(--rule); }
.mu-set-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.375rem;
    font-size: 0.9375rem;
}
.mu-sets .actions { margin: 0 0 0.5rem; }
.mu-edit-foot { margin: 0 0 2rem; }
.mu-volume table { margin-top: 0.5rem; }
.mu-volume .hint { margin: 0.75rem 0 0; }
@media (max-width: 36rem) {
    .mu-fields { grid-template-columns: 3.75rem repeat(3, minmax(0, 1fr)); }
}

/* Message temporaire en bas de l'écran. Il laisse passer les appuis vers la page,
   sauf sur son bouton. */
.mu-toast {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: max-content;
    max-width: calc(100vw - 2rem);
    padding: 0.625rem 0.75rem 0.625rem 1rem;
    border-radius: var(--r-control);
    background: var(--ink);
    color: var(--bg);
    font-size: 0.9375rem;
    pointer-events: none;
    animation: fade 180ms ease;
}
.mu-toast button {
    flex: none;
    border-color: color-mix(in srgb, var(--bg) 55%, transparent);
    color: var(--bg);
    pointer-events: auto;
}

/* Séance en cours : plein écran, par-dessus le bandeau, avec sa propre barre */
body.mu-live-open { overflow: hidden; }
.mu-live {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
/* Le repos se reconnaît de loin à son fond, en plus de son libellé. */
.mu-live[data-phase="repos"] { background: var(--panel); }
.mu-live-top {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.25rem;
    padding: 0.25rem var(--gutter);
    background: var(--header-bg);
    color: var(--header-ink);
}
.mu-live-top p { margin: 0; }
.mu-live-top button { flex: none; margin-left: -0.625rem; color: var(--header-ink); }
.mu-live-top :focus-visible { outline-color: var(--header-ink); }
.mu-live-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
    text-align: center;
}
.mu-live-total { flex: none; font-size: 1.125rem; font-weight: 700; font-stretch: 90%; }
.mu-live-body {
    flex: 1;
    width: 100%;
    max-width: 40rem;
    min-height: 0;
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.mu-live-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.mu-live-body .section-title { margin-bottom: 0.375rem; }
.mu-live-body > .hint { margin-bottom: 0; }
.mu-live-foot {
    flex: none;
    display: grid;
    gap: 0.5rem;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
/* Le bouton de la séance : sous le pouce, toute la largeur */
button.mu-big {
    width: 100%;
    min-height: 4rem;
    font-size: 1.25rem;
    font-weight: 700;
    font-stretch: 90%;
}
.mu-live-more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.25rem 0.75rem;
    font-size: 0.9375rem;
}
.mu-live-name {
    font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2rem);
    font-weight: 750;
    font-stretch: 88%;
    letter-spacing: -0.015em;
    line-height: 1.1;
    overflow-wrap: anywhere;
}
.mu-live-step { margin: 0.375rem 0 0; font-weight: 500; color: var(--ink-2); }

/* Cadran : le temps au centre d'un anneau. Série en cours : anneau plein en
   --link, et un point qui fait un tour par minute. Repos : l'anneau, en --ink,
   se vide. Le SVG vient de musculation.js ; ses couleurs viennent d'ici. */
.mu-dial {
    position: relative;
    flex: none;
    width: min(16.5rem, 62vw, 38dvh);
    aspect-ratio: 1;
    margin: 1rem 0 0.75rem;
}
.mu-dial svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mu-dial-track { fill: var(--surface); stroke: var(--rule); stroke-width: 8; }
.mu-dial-arc { fill: none; stroke: var(--link); stroke-width: 8; }
.mu-dial-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 3; }
[data-phase="repos"] .mu-dial-arc { stroke: var(--ink); }
[data-phase="repos"] .mu-dial-dot { display: none; }
[data-phase="repos"].is-over .mu-dial-arc { stroke: var(--link); }
.mu-dial-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.mu-dial-label { font-size: 0.875rem; font-weight: 500; color: var(--ink-2); }
/* Un chrono change à chaque seconde : chiffres tabulaires, pour qu'il ne tremble pas. */
.mu-dial-time {
    font-size: clamp(2.75rem, 13vw, 3.75rem);
    font-weight: 800;
    font-stretch: 85%;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.05;
}
.mu-dial-time.is-long { font-size: clamp(2rem, 9.5vw, 2.75rem); }

.mu-live-target, .mu-live-next { display: grid; gap: 0.125rem; margin: 0.25rem 0 0; }
.mu-live-target span, .mu-live-next span { font-size: 0.8125rem; color: var(--ink-2); }
.mu-live-target strong { font-size: 1.375rem; font-weight: 700; font-stretch: 90%; line-height: 1.2; }
.mu-live-next { margin-top: 1rem; }
.mu-live-next strong { font-weight: 650; }
.mu-live-note {
    max-width: 100%;
    margin-top: 0.75rem;
    font-size: 0.9375rem;
    text-align: left;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.mu-live-last { margin: 0.75rem 0 0; }
.mu-adjust { display: flex; justify-content: center; gap: 0.5rem; }
.mu-adjust button { min-width: 5.5rem; font-variant-numeric: tabular-nums; }

/* Ce qui vient d'être fait, à corriger pendant le repos, ou en tête de la liste
   des exercices après la dernière série d'un exercice (.mu-done-top) */
.mu-done {
    display: grid;
    gap: 0.625rem;
    justify-items: center;
    width: 100%;
    margin-top: 1rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--field-border);
}
.mu-done p { margin: 0; font-size: 0.9375rem; }
.mu-done-fields { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem 1rem; }
.mu-done-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.5rem; }
.mu-done-top {
    justify-items: start;
    margin: 0 0 1.25rem;
    padding: 0 0 1rem;
    border-top: 0;
    border-bottom: 1px solid var(--field-border);
}
.mu-done-top .mu-done-fields, .mu-done-top .mu-done-links { justify-content: flex-start; }
.mu-done p.mu-done-name { font-size: 1rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }

/* Corriger les séries déjà faites : un exercice sous un filet fort, une série par groupe de cases */
.mu-fix { margin-top: 1.25rem; padding-top: 0.625rem; border-top: 2px solid var(--ink); }
.mu-fix h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.mu-fix fieldset { margin: 0.875rem 0 0; padding: 0 0 0.875rem; border-bottom: 1px solid var(--rule); }
.mu-fix legend { margin-bottom: 0.5rem; font-size: 0.9375rem; font-weight: 600; }
.mu-fix .mu-done-fields { justify-content: flex-start; }
.mu-stepper { display: grid; grid-template-columns: 2.75rem 4rem 2.75rem; align-items: end; gap: 0.25rem; }
.mu-stepper label { grid-column: 1 / -1; font-size: 0.8125rem; color: var(--ink-2); text-align: center; }
.mu-stepper input { margin-top: 0; padding-inline: 0.25rem; font-weight: 650; text-align: center; }
.mu-stepper button { padding: 0; font-size: 1.25rem; }

/* Liste des exercices de la séance */
.mu-rest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}
.mu-rest p { display: flex; align-items: baseline; gap: 0.625rem; margin: 0; font-weight: 500; }
.mu-rest-time {
    font-size: 1.75rem;
    font-weight: 750;
    font-stretch: 88%;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.mu-live-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    border-top: 2px solid var(--ink);
}
.mu-live-item {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    column-gap: 0.625rem;
    align-items: center;
    padding: 0.625rem 0.5rem;
    border-bottom: 1px solid var(--rule);
}
.mu-live-item > div { display: grid; min-width: 0; }
.mu-live-item strong { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.mu-live-item .dish-meta { overflow-wrap: anywhere; }
.mu-live-n { font-size: 0.9375rem; color: var(--ink-2); }
/* L'exercice conseillé : même fond qu'une ligne sélectionnée, et le bouton principal. */
.mu-live-item[data-conseille] { background: var(--selected); }
.mu-live-item[data-etat="fini"] strong { font-weight: 500; color: var(--ink-2); }

/* Pendant un repos, « Voir les exercices » (lien sur la ligne « Repos après la
   série… ») : la liste de la séance sur le fond de page, et le minuteur dans une
   bande qui ne défile pas, au fond du repos. La série qui suit a le fond
   --selected, comme l'exercice conseillé de la liste, et une ligne « Ensuite ». */
.mu-step-peek { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 1rem; }
.mu-live[data-apercu] { background: var(--bg); }
.mu-peek { flex: none; background: var(--panel); border-bottom: 1px solid var(--field-border); }
.mu-peek-in {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    max-width: 40rem;
    margin: 0 auto;
    padding: 0.5rem var(--gutter);
}
.mu-peek p { display: grid; margin: 0; }
.mu-peek p span { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.mu-peek button { flex: none; }
.mu-peek-title:focus { outline: none; }
.mu-live-item[data-suivant] { background: var(--selected); }
.mu-live-suivant { margin-top: 0.125rem; font-size: 0.875rem; font-weight: 600; overflow-wrap: anywhere; }

/* Bilan et historique */
.mu-live-body .progress { margin: 0.75rem 0 1.25rem; }
.mu-live-body > .notice { margin-top: 0.5rem; }
.mu-recap { margin-bottom: 0.5rem; }
.mu-recap-fix { margin: 0 0 1.25rem; font-size: 0.9375rem; }
.mu-recap td { overflow-wrap: anywhere; }
/* Ici la dernière colonne porte l'essentiel : elle reste lisible, à gauche. */
.data-table.mu-recap tr > :last-child { font-size: inherit; color: inherit; text-align: left; }
.data-table.mu-recap thead tr > :last-child { font-size: 0.8125rem; color: var(--ink-2); }
.mu-gaps ul { margin: 0; padding-left: 2rem; }
.mu-follow { margin-bottom: 2.5rem; }
.mu-follow .section-title { margin-bottom: 1rem; }
.mu-follow-choice { max-width: 26rem; }
.mu-log { padding: 0.875rem 0 1.5rem; border-top: 2px solid var(--ink); }
.mu-log h3 { font-size: 1.0625rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.mu-log p { margin: 0; }
.mu-log .mu-recap { margin: 0.75rem 0 0; border-top-width: 1px; border-top-color: var(--field-border); }
.mu-log .mu-log-note {
    max-width: 34rem;
    margin-top: 0.75rem;
    font-size: 0.9375rem;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.mu-log .dish-actions, .mu-log > .actions { align-items: center; margin-top: 0.625rem; font-size: 0.875rem; }
.mu-history .mu-sync { margin-top: 1.5rem; }

@media (hover: hover) and (pointer: fine) {
    .mu-toast button:hover:not(:disabled) { background: color-mix(in srgb, var(--bg) 16%, transparent); }
    .mu-live-top button:hover:not(:disabled) {
        background: color-mix(in srgb, var(--header-ink) 14%, transparent);
    }
}
@media (pointer: coarse) {
    .mu-fields input, .mu-set-fields input, .mu-set-fields select, .mu-stepper input { min-height: 2.75rem; }
}

/* ---------- Journal alimentaire ----------
   Classes propres à la page, toutes préfixées jr- ; le reste vient des
   composants communs (.milestones, .progress, .panel, .facts, .data-table,
   .mu-choices, .mu-toast…). Les listes de la page et les étapes du dialogue
   sont construites par journal.js. */

.jr-head { justify-content: space-between; margin-bottom: 1.25rem; }
.jr-head .link { flex: none; font-size: 0.9375rem; }

/* Jour affiché : veille, date, lendemain sur une ligne */
.jr-day { display: flex; align-items: flex-end; gap: 0.5rem; }
.jr-day .field { flex: 0 1 11rem; min-width: 0; margin: 0; }
.jr-day button { flex: none; }
/* Sur téléphone, la date a toute la ligne et les deux boutons se partagent
   celle du dessous : la date reste lisible même avec un texte agrandi dans
   les réglages du téléphone. (Le débordement vu sur iPhone venait d'ailleurs :
   voir input[type="date"] dans « Formulaires ».) */
@media (max-width: 36rem) {
    .jr-day { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .jr-day .field { grid-column: 1 / -1; grid-row: 1; }
}
.jr-day-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1rem;
    margin: 0.75rem 0 1.5rem;
}
.jr-day-title strong { font-size: 1.0625rem; font-weight: 650; }
.jr-day-title .link { font-size: 0.9375rem; }
#jr-error { margin: 0 0 1rem; }

/* Bilan, repas et semaine à gauche ; ajout et objectifs à droite. Sur une
   colonne, le code donne la suite : bilan, ajout, repas, semaine. */
.jr-layout { display: grid; gap: 2.25rem; }
.jr-layout > * { min-width: 0; }
@media (min-width: 60rem) {
    .jr-layout {
        grid-template-columns: minmax(0, 1fr) 22.5rem;
        column-gap: 3.5rem;
        row-gap: 2.75rem;
        align-items: start;
    }
    .jr-layout > * { grid-column: 1; }
    .jr-layout > .jr-side { grid-column: 2; grid-row: 1 / span 4; }
}

/* Bilan : objectif, reste, consommé (.milestones), puis les trois macros */
.jr-summary .milestones { padding-bottom: 1rem; }
.jr-summary .is-current .milestone-value { font-size: clamp(2.25rem, 1.3rem + 4vw, 3.5rem); }
.jr-summary .milestone-date .link { font-size: 0.9375rem; }
#jr-kcal-bar:not(:empty) { padding-bottom: 1.25rem; }
/* Part déjà consommée du total visé. Le chiffre est toujours écrit à côté. */
.jr-bar {
    appearance: none;
    display: block;
    width: 100%;
    height: 0.375rem;
    border: 0;
    border-radius: 2px;
    background: var(--rule);
    color: var(--link);
    overflow: hidden;
}
.jr-bar::-webkit-progress-bar { background: var(--rule); }
.jr-bar::-webkit-progress-value { background: var(--link); }
.jr-bar::-moz-progress-bar { background: var(--link); }
.jr-summary .progress .jr-bar { margin-top: 0.375rem; }
/* Trois valeurs courtes : elles restent côte à côte sur téléphone. */
@media (max-width: 36rem) {
    .jr-summary .progress {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0 1rem;
        padding: 0.875rem 0;
    }
    .jr-summary .progress > div { padding: 0; }
    .jr-summary .progress > div + div { border-top: 0; }
}

/* Ajout et objectifs */
.jr-side .actions { margin: 0 0 1rem; }
.jr-side .actions > * { flex: 1 1 100%; }
.jr-side > .hint { margin-bottom: 0; }
.jr-side h3 {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--field-border);
    font-size: 0.9375rem;
    font-weight: 700;
}
.jr-side .facts { margin-top: 0.5rem; }
#jr-goals .hint { margin: 0.5rem 0 0; }
#jr-goals .link { margin-top: 0.75rem; font-size: 0.9375rem; }

/* Un repas : filet fort, une ligne par aliment, total des macros */
.jr-meals { display: grid; gap: 1.75rem; }
.jr-meal { padding-top: 0.75rem; border-top: 2px solid var(--ink); }
.jr-meal-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}
.jr-meal-head h2 { font-size: 1.0625rem; font-weight: 700; }
.jr-meal-kcal {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    font-stretch: 90%;
    white-space: nowrap;
}
.jr-entries { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.jr-entries li { border-top: 1px solid var(--rule); }
/* Toute la ligne se touche : elle ouvre la quantité, le repas et la suppression. */
button.jr-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    align-items: baseline;
    width: 100%;
    min-height: 3rem;
    padding: 0.5rem 0.25rem;
    border: 0;
    border-radius: 0;
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
}
button.jr-entry:active:not(:disabled) { transform: none; }
.jr-entry-name { display: grid; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.jr-entry-name .dish-meta { margin-top: 0; font-weight: 400; }
.jr-entry-kcal { white-space: nowrap; }
.jr-meal .facts {
    margin: 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--field-border);
    font-size: 0.875rem;
}
.jr-meal .dish-actions { margin-top: 0.625rem; font-size: 0.9375rem; }

/* Sept derniers jours */
.jr-week .section-title { margin-bottom: 1rem; }
/* Ici la dernière colonne est une valeur comme les autres. */
.data-table.jr-week-table tr > :last-child,
.data-table.jr-label tr > :last-child { font-size: inherit; color: inherit; }
.data-table.jr-week-table thead tr > :last-child { font-size: 0.8125rem; color: var(--ink-2); }
.jr-week-table tfoot th, .jr-week-table tfoot td {
    border-top: 1px solid var(--field-border);
    border-bottom: 0;
    font-weight: 600;
}
.jr-week-table .link { font-size: inherit; }
.jr-about .hint { max-width: 42rem; margin: 0; }

/* Le dialogue et ses étapes */
@media (min-width: 40.01rem) {
    #jr-dialog { width: min(32rem, calc(100vw - 2rem)); }
}
#jr-dialog h2:focus { outline: none; }
#jr-dialog form > .notice { margin: 0 0 1rem; }
.jr-ways { margin: 0 0 0.25rem; }
.jr-ways > button { flex: 1 1 auto; }
.jr-results h3 {
    margin: 1.25rem 0 0;
    padding-top: 0;
    border-top: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink-2);
}
.mu-choices.jr-choices { margin-top: 0.375rem; }
.jr-results > .hint { margin: 1rem 0 0; }
.jr-results > .actions { margin-top: 0.75rem; }

.jr-saved { margin: 0 0 1rem; }
.jr-food-name {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 650;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.jr-food-name + .dish-meta { margin: 0.125rem 0 1rem; overflow-wrap: anywhere; }
/* Quantité et repas côte à côte, même sur téléphone */
.field-grid.jr-quantity { grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); align-items: end; }
.jr-presets { margin: -0.25rem 0 1rem; }
.jr-presets button { min-height: 2.25rem; padding: 0 0.75rem; font-size: 0.875rem; }
dialog .jr-presets > button { flex: 0 1 auto; }
/* Ce que représente la quantité saisie */
.jr-result {
    padding: 0.625rem 0 0.75rem;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--field-border);
}
.jr-result .facts { margin-top: 0.125rem; }
.jr-result .hint { margin: 0; }
.jr-details { margin: 1.5rem 0 0; }
.jr-details .hint { margin: 0.75rem 0 0; }
.jr-details .link { font-size: inherit; }
.jr-label caption {
    padding-bottom: 0.5rem;
    text-align: left;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.jr-label th.jr-sub { padding-left: 1rem; font-weight: 400; color: var(--ink-2); }
.jr-delete {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    font-size: 0.9375rem;
}

/* Étiquette à recopier : une valeur par ligne, comme sur un emballage */
.jr-label-fields { margin-bottom: 0.75rem; border-top: 1px solid var(--field-border); }
.jr-label-fields .field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6.5rem;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 0.3125rem 0;
    border-bottom: 1px solid var(--rule);
}
.jr-label-fields .field.jr-sub { padding-left: 1rem; font-weight: 400; color: var(--ink-2); }
.jr-label-fields input { margin-top: 0; text-align: right; }

/* Scan : image de la caméra, et le cadre où placer le code-barres */
.jr-scan {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 46dvh;
    border-radius: var(--r-control);
    background: var(--panel);
}
.jr-scan video { display: block; width: 100%; height: 100%; object-fit: cover; }
.jr-scan-frame {
    position: absolute;
    inset: 26% 7%;
    border: 2px solid var(--surface);
    border-radius: var(--r-control);
    outline: 1px solid var(--ink);
}
.jr-scan-status { margin: 0.75rem 0 0; }
.jr-scan-status + .actions { margin-top: 0.75rem; }
.jr-manual { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

@media (pointer: coarse) {
    .jr-presets button, .jr-label-fields input { min-height: 2.75rem; }
}

/* ---------- Pied de page ---------- */

.site-footer {
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 0 var(--gutter) 2rem;
    font-size: 0.8125rem;
    color: var(--ink-2);
}
.site-footer p { margin: 0; padding-top: 1rem; border-top: 1px solid var(--rule); }
.site-footer a { color: inherit; }

/* ---------- Page de confidentialité ---------- */

.prose { max-width: 42rem; }
.prose h1 {
    margin-bottom: 1.5rem;
    font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.25rem);
    font-weight: 750;
    font-stretch: 88%;
    letter-spacing: -0.015em;
    line-height: 1.1;
}
.prose h2 {
    margin: 2.25rem 0 0.625rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    font-size: 1.125rem;
    font-weight: 700;
}
.prose p, .prose ul { margin: 0 0 1rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: 0.5rem; }
.prose mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* ---------- Mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
    .combo { animation-name: fade; animation-delay: 0ms; }
    dialog, dialog[open] { transform: none; }
    .site-menu, .site-header.is-open .site-menu { transform: none; }
    .menu-icon::before, .menu-icon::after { transition: none; }
    button:active:not(:disabled), a.button:active { transform: none; }
}
