:root {
    --bg: #F6F3EC;
    --surface: #FFFFFF;
    --ink: #24352D;
    --muted: #5F6B63;
    --card: #FFFFFF;
    --accent: #31594B;
    --accent-ink: #FFFFFF;
    --sage: #E3ECE5;
    --terracotta: #B85C40;
    --line: #DCE3DA;
    --space: 0.8rem;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(36, 53, 45, 0.06);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background:
        radial-gradient(circle at top left, rgba(227, 236, 229, 0.7), transparent 28rem),
        var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

a:where(:not(.button)),
a:where(:not(.button)):visited,
a:where(:not(.button)):hover,
a:where(:not(.button)):active {
    color: var(--accent);
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.4rem;
    background: var(--accent);
    color: var(--accent-ink);
}

.brand {
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}

.topbar-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.compte {
    position: relative;
}

.compte-menu {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 5;
    min-width: 12rem;
    background: #fffdf8;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.4rem;
}

.compte-menu a,
.compte-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--ink);
    border: 0;
    padding: 0.4rem 0.5rem;
}

.plage {
    border: 0;
    margin: 0 0 0.8rem;
    padding: 0;
}

.plage-lignes,
.plage-nombres,
.tris {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.plage-lignes input[type="range"] {
    flex: 1 1 8rem;
}

.plage-nombres input {
    width: 5rem;
}

.topbar-nav a {
    color: var(--accent-ink);
    text-decoration: none;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
}

.topbar-nav a[aria-current="page"] {
    background: var(--sage);
    color: var(--ink);
}

.topbar-nav .user {
    font-size: 0.95rem;
    opacity: 0.9;
}

.topbar-nav form {
    margin: 0;
}

button,
.topbar-nav button {
    font: inherit;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
    border: 0;
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
}

.topbar-nav button {
    background: transparent;
    color: #f8f4ec;
    border: 1px solid #9fb8b3;
}

.topbar .compte-menu a,
.topbar .compte-menu button {
    background: transparent;
    color: var(--ink);
    border: 0;
}

.topbar .compte-menu a:hover,
.topbar .compte-menu button:hover {
    background: var(--sage);
    color: var(--ink);
}

.container {
    max-width: 64rem;
    margin: 2rem auto;
    padding: 0 1.2rem 3rem;
}

h1 {
    font-size: 1.7rem;
    margin-bottom: 0.6rem;
}

.card-form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.2rem 1.3rem;
}

.card-form p {
    margin: 0 0 0.9rem;
}

.card-form label {
    display: block;
    margin-bottom: 0.25rem;
}

.card-form input,
.card-form select {
    width: 100%;
    font: inherit;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.errorlist {
    color: #9b1c1c;
    padding-left: 1.1rem;
}

.messages {
    background: #e8f0ee;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    list-style: none;
}

.button,
.button:hover,
.button:focus,
.button:active,
.button:visited {
    display: inline-block;
    font: inherit;
    text-decoration: none;
    background: var(--accent);
    color: var(--accent-ink);
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
}

.button-link,
.button-link:hover,
.button-link:focus,
.button-link:active,
.button-link:visited {
    display: inline-block;
    font: inherit;
    text-decoration: none;
    background: transparent;
    color: var(--accent);
    border-radius: 6px;
    padding: 0.45rem 0.85rem;
    margin-left: 0.5rem;
}

.button-secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    margin-left: 0.5rem;
}

.helptext {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
}

table.data th,
table.data td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data img {
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    object-fit: cover;
}

.actions {
    white-space: nowrap;
}

.actions a {
    color: var(--accent);
    margin-right: 0.6rem;
}

.empty {
    color: var(--muted);
}

.avantage {
    color: #0f766e;
    font-weight: 700;
}

.peu-avantage {
    color: #9b1c1c;
    font-weight: 700;
}

.comparable {
    color: var(--muted);
}

h3 {
    margin: 1.6rem 0 0.5rem;
    font-size: 1.15rem;
}

.recette-image {
    display: block;
    width: 240px;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.recette-vignette {
    display: block;
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #eee;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.pagination a {
    color: var(--accent);
}

.card-form select[name="sens"],
.card-form select[name="sens2"] {
    margin-top: 0.35rem;
}

.stats-resume {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem 1.4rem;
    padding: 0;
    list-style: none;
}

.muted {
    color: var(--muted);
}

.garde-details summary {
    cursor: pointer;
    list-style-position: outside;
}

.garde-details ul {
    margin: 0.4rem 0 0.2rem 1.1rem;
    padding: 0;
}

.garde-details li {
    margin: 0.15rem 0;
}

.barre-fond {
    display: block;
    width: 100%;
    max-width: 14rem;
    height: 0.55rem;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
}

.barre {
    display: block;
    width: 0;
    max-width: 100%;
    height: 100%;
    background: var(--accent);
}

.rayon-titre {
    margin: 1.8rem 0 0.6rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--line);
    font-size: 1.2rem;
}

body.menu-page .container {
    max-width: 92rem;
}

.menu-grille {
    display: grid;
    grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr) minmax(16rem, 22rem);
    gap: 1.2rem;
    align-items: start;
}

.menu-carte {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.1rem 1.2rem;
}

.menu-choisi {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-colonne {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.menu-alerte {
    background: #fbe9e7;
    border: 1px solid #e8b4b0;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    color: #7a1f1a;
}

.menu-choisi li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--line);
}

.menu-choisi-infos {
    min-width: 0;
}

.portions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.portions-btn {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
    min-width: 1.8rem;
    padding: 0.15rem 0.4rem;
}

.portions-saisie {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
}

.portions-saisie input {
    width: 3.2rem;
    padding: 0.15rem 0.3rem;
}

.courses-liste {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
}

.menu-choisi form {
    margin: 0;
    flex-shrink: 0;
}

.bouton-retirer {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.lien-bouton {
    background: none;
    color: var(--accent);
    border: 0;
    padding: 0;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.titre-recette {
    font-weight: 700;
}

@media (max-width: 900px) {
    .menu-grille {
        grid-template-columns: 1fr;
    }
}

.menu-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 22.5rem);
    gap: 1rem;
    align-items: start;
}

.menu-principal,
.menu-panneau,
.carte-recette,
.liste-stocks li,
.liste-utiles li,
.cartes-bilan li {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu-principal,
.menu-panneau {
    padding: 1rem;
}

.menu-panneau {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-width: 0;
    container-type: inline-size;
    container-name: menupanel;
}

.bloc-enregistrer h2,
#menu-selection h2 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
}

.bloc-enregistrer form {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
}

.bloc-enregistrer input,
.bloc-enregistrer button {
    width: 100%;
    max-width: 100%;
}

.lien-historique {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
}

.filtres-duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.piste {
    position: relative;
    height: 1.6rem;
    margin: 0.6rem 0.7rem 0.2rem;
}

.piste-rail,
.piste-segment {
    position: absolute;
    top: 0.55rem;
    height: 0.35rem;
    border-radius: 999px;
}

.piste-rail {
    left: 0;
    right: 0;
    background: var(--sage);
}

.piste-segment {
    background: var(--accent);
}

.piste-poignee {
    position: absolute;
    top: 0.15rem;
    width: 1.15rem;
    height: 1.15rem;
    margin-left: -0.55rem;
    padding: 0;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: var(--surface);
    touch-action: none;
}

.barre-resultats,
.vues {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.8rem 0;
}

.vues a,
.barre-resultats a {
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    background: var(--surface);
}

.vues a[aria-current="page"],
.barre-resultats a[aria-current="true"],
.tris button[aria-pressed="true"] {
    background: var(--sage);
    color: var(--ink);
}

.cartes-recettes,
.vignettes,
.liste-stocks,
.liste-utiles,
.cartes-bilan {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cartes-recettes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.8rem;
}

.carte-recette {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.7rem;
    min-width: 0;
    height: 100%;
    position: relative;
}

.carte-lien {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1 1 auto;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.recherche {
    margin: 0 0 0.9rem;
}

.recherche input {
    width: 100%;
    min-height: 2.9rem;
    padding: 0.6rem 0.9rem 0.6rem 2.6rem;
    border: 1px solid #8ea197;
    border-radius: 10px;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F6B63' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem 50%;
    background-size: 1.05rem;
    font: inherit;
    color: var(--ink);
}

.carte-pied {
    margin-top: auto;
    display: grid;
    grid-template-rows: 1.45rem 1.45rem auto;
    gap: 0.35rem;
}

.carte-pied p {
    margin: 0;
    line-height: 1.45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.carte-action {
    width: 100%;
}

.carte-recette.est-choisie {
    outline: 2px solid var(--accent);
}

.carte-recette.est-choisie::after {
    content: "Choisie";
    position: absolute;
    top: 0.85rem;
    left: 0.85rem;
    padding: 0.1rem 0.35rem;
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
}

.vignette {
    color: inherit;
    text-decoration: none;
}

.carte-recette .carte-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    flex: 0 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--sage), #f6f3ec 70%);
}

.carte-recette .carte-photo img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: center;
    border: 0;
    background: transparent;
}

.carte-titre {
    display: block;
    font-weight: 650;
}

.badge {
    display: inline-block;
    margin: 0 0.25rem 0.25rem 0;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--sage);
    color: var(--ink);
    font-size: 0.8rem;
}

.vignettes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.vignettes > li,
.menu-panneau,
#menu-selection,
.menu-selection {
    min-width: 0;
    max-width: 100%;
}

.vignettes > li {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.vignette {
    position: relative;
    display: block;
    min-width: 0;
    max-width: 100%;
}

.vignette-photo {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--sage), #f6f3ec 70%);
}

.vignette-photo img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: center;
}

.vignette-nom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.35rem;
    background: rgba(36, 53, 45, 0.82);
    color: #fff;
    font-size: 0.78rem;
    opacity: 0;
}

.vignette:hover .vignette-nom,
.vignette:focus .vignette-nom,
.vignette:focus-within .vignette-nom {
    opacity: 1;
}

.portions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 0;
}

.portions-saisie {
    min-width: 0;
    justify-content: center;
}

.portions-saisie span {
    font-size: 0.8rem;
}

.portions-saisie input {
    width: 2.4rem;
    min-width: 0;
    appearance: textfield;
    -moz-appearance: textfield;
}

.bouton-retirer,
.carte-action {
    max-width: 100%;
}

.portions-saisie input::-webkit-outer-spin-button,
.portions-saisie input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

button.button-secondary,
button.apercu-fermer {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

button.bouton-retirer {
    background: transparent;
    color: var(--terracotta);
    border: 1px solid var(--terracotta);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.aller-menu {
    display: none;
}

dialog.apercu {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    overflow: hidden;
}

.apercu-panneau {
    margin-left: auto;
    width: min(36rem, 100%);
    height: 100%;
    overflow: auto;
    background: var(--surface);
    border-left: 1px solid var(--line);
    padding: 1rem 1rem 1.4rem;
    box-shadow: var(--shadow);
}

dialog.apercu::backdrop {
    background: rgba(36, 53, 45, 0.45);
}

.cartes-bilan {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.cartes-bilan li,
.liste-stocks li,
.liste-utiles li {
    padding: 0.8rem;
}

.cartes-bilan strong {
    display: block;
    font-size: 1.6rem;
}

.note {
    background: var(--sage);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

.liste-stocks li,
.liste-utiles {
    display: grid;
    gap: 0.6rem;
}

.liste-stocks {
    display: grid;
    gap: 0.5rem;
}

.liste-stocks li {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.liste-stocks form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.interrupteur {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.interrupteur.est-present {
    background: var(--sage);
    color: var(--ink);
}

.menu-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 30;
    max-width: min(24rem, calc(100% - 2rem));
    margin: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: var(--shadow);
    animation: menu-toast-in 0.28s ease;
}

@keyframes menu-toast-in {
    from { opacity: 0; transform: translateY(0.4rem); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .menu-toast {
        animation: none;
    }
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

@media (min-width: 901px) {
    .menu-panneau {
        position: sticky;
        top: 0.8rem;
        display: flex;
        max-height: calc(100vh - 1.6rem);
        overflow: hidden;
    }

    .bloc-enregistrer {
        position: static;
        flex: 0 0 auto;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        padding-bottom: 0.7rem;
    }

    .menu-defile {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding-top: 0.7rem;
    }

    .vignette-nom {
        opacity: 0;
    }
}

@media (max-width: 900px) {
    .menu-layout,
    .filtres-duo,
    .cartes-bilan {
        grid-template-columns: 1fr;
    }

    .aller-menu {
        display: inline-block;
        margin-bottom: 0.6rem;
    }

    .vignette-nom {
        position: static;
        opacity: 1;
        background: transparent;
        color: var(--ink);
        padding: 0.3rem 0 0;
    }

    dialog.apercu {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem;
    }

    .apercu-panneau {
        margin: 0;
        width: 100%;
        height: auto;
        max-height: 100%;
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }

    .container {
        overflow-x: hidden;
    }

    .bloc-enregistrer {
        position: static;
    }

    .menu-defile {
        overflow: visible;
    }
}

.vignettes .portions {
    grid-template-columns: 1.6rem minmax(0, 1fr) 1.6rem;
    justify-items: center;
    gap: 0.15rem 0.2rem;
}

.vignettes .portions-libelle {
    grid-column: 1 / -1;
    font-size: 0.72rem;
    line-height: 1.1;
    color: var(--muted);
}

.vignettes .portions-btn {
    min-width: 1.6rem;
    padding: 0.1rem 0.15rem;
}

.vignettes .portions-saisie,
.vignettes .portions-saisie input {
    width: 100%;
    max-width: 100%;
    text-align: center;
}

.vignettes .bouton-retirer {
    width: 100%;
    padding: 0.2rem 0.3rem;
}

@container menupanel (max-width: 15.5rem) {
    .vignettes {
        grid-template-columns: 1fr;
    }
}
