/* ============================================
   PITCHU CUISINE — styles (V3)
   Complète budget.css ; pensé mobile d'abord.
   ============================================ */

.cuisine-main { max-width: 1100px; }

/* Sur iPhone, deux taps rapprochés sur un bouton (ou juste à côté)
   déclenchent le zoom de Safari : on le désactive pour tous les boutons */
button, .btn-icon, .chip-btn { touch-action: manipulation; }

.cuisine-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.cuisine-search {
    width: 100%;
    margin-bottom: 1.25rem;
    min-height: 48px;
    font-size: 1rem;
}

/* ---- Grille de cartes ---- */

.cuisine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
}

.cuisine-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Numéro unique de la recette (#01, #02...) */
.cuisine-card-numero {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    background: var(--accent-light);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.cuisine-detail-numero {
    display: inline-block;
    background: var(--accent-light);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.cuisine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.cuisine-card-emoji { font-size: 2rem; line-height: 1; }

.cuisine-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cuisine-card-context {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cuisine-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
}

.cuisine-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.cuisine-card-stars {
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.cuisine-stars-filled { color: #f59e0b; }
.cuisine-stars-empty { color: var(--border); }

.cuisine-card-stars .cuisine-avis-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: normal;
    margin-left: 0.3rem;
}

.cuisine-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

/* ---- Détail d'une recette ---- */

.cuisine-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    max-width: 820px;
    margin: 0 auto;
}

.cuisine-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.cuisine-detail-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.cuisine-detail-context {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.cuisine-detail-actions { display: flex; gap: 0.5rem; }

.cuisine-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.5rem 0 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cuisine-ingredients { list-style: none; padding: 0; }

.cuisine-ingredients li {
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.92rem;
}

.cuisine-ingredients li::before { content: '• '; color: var(--accent); font-weight: 700; }

/* Étapes en cartes numérotées : lisibles sur grand écran comme sur mobile */
.cuisine-etapes {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.cuisine-etape-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 0.8rem 1rem;
}

.cuisine-etape-num {
    flex: 0 0 auto;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cuisine-etape-text {
    font-size: 0.98rem;
    line-height: 1.6;
    padding-top: 0.15rem;
    overflow-wrap: anywhere;
}

.cuisine-macros-table {
    width: 100%;
    /* Annule le min-width global des tables de budget.css qui cassait
       toute la mise en page mobile (débordement horizontal). */
    min-width: 0;
    border-collapse: collapse;
    text-align: center;
}

.cuisine-macros-table th {
    background: var(--bg);
    padding: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.cuisine-macros-table td {
    padding: 0.6rem;
    font-weight: 700;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.cuisine-conservation {
    background: var(--bg);
    border-left: 3px solid var(--accent);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-secondary);
    white-space: pre-line;
}

/* ---- Avis ---- */

.cuisine-avis-block {
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.cuisine-avis-user {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.cuisine-avis-comment {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
    white-space: pre-line;
}

.cuisine-avis-empty { color: var(--text-muted); font-size: 0.85rem; }

.cuisine-star-picker { display: flex; gap: 0.2rem; }

.cuisine-star-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0.1rem;
    color: var(--border);
    transition: transform 0.1s ease;
}

.cuisine-star-btn.filled { color: #f59e0b; }
.cuisine-star-btn:hover { transform: scale(1.15); }

.cuisine-avis-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.cuisine-avis-form textarea { min-height: 60px; font-size: 0.95rem; }

.cuisine-avis-form .btn-primary { align-self: flex-start; }

/* ---- Modal ajout/édition ---- */

.cuisine-modal { max-width: 640px; width: calc(100% - 2rem); }

.cuisine-title-row { display: flex; gap: 0.5rem; }

.cuisine-emoji-input { width: 4.2rem; text-align: center; font-size: 1.3rem; }

.cuisine-title-row .form-input:last-child { flex: 1; }

.cuisine-textarea { font-family: inherit; resize: vertical; line-height: 1.5; }

.cuisine-macros-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.5rem;
}

/* Champs d'étapes dynamiques dans le modal */
.cuisine-etapes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.cuisine-etape-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.cuisine-etape-row-num {
    flex: 0 0 auto;
    width: 1.7rem;
    height: 1.7rem;
    margin-top: 0.5rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cuisine-etape-row .cuisine-etape-input {
    flex: 1;
    resize: vertical;
    line-height: 1.5;
    font-family: inherit;
    min-height: 52px;
}

.cuisine-etape-remove {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    width: 2rem;
    height: 2rem;
    margin-top: 0.35rem;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.cuisine-etape-remove:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.cuisine-add-etape { display: inline-flex; align-items: center; gap: 0.35rem; }

/* ============================================
   FILTRES DE LA LISTE DE RECETTES
   ============================================ */

.cuisine-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.cuisine-filter-select {
    flex: 1;
    min-width: 150px;
    min-height: 44px;
    font-size: 0.9rem;
}

.cuisine-day-filter {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.cuisine-day-filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 0.15rem;
}

/* ---- Boutons "chips" génériques (jours, mangeur, type de repas...) ---- */

.chip-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 38px;
}

.chip-btn:hover { border-color: var(--accent); color: var(--accent-dark); }

.chip-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chips-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.cuisine-chip-jours { background: var(--accent-light); color: var(--accent-dark); border-color: transparent; }

.cuisine-jours-picker {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.label-hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cuisine-detail-jours {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* ============================================
   JOURNAL (dashboard nutrition)
   ============================================ */

.journal-eater-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.journal-eater-row .eater-chip { flex: 1; text-align: center; min-height: 44px; }

.journal-date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    /* Un double tap sur ou à côté des flèches ne déclenche plus le zoom Safari */
    touch-action: manipulation;
}

.journal-date-arrow {
    min-width: 44px;
    min-height: 48px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text-secondary);
    touch-action: manipulation;
}

/* Flèches de changement de jour bien larges : difficiles à rater au pouce */
.journal-date-nav .journal-date-arrow {
    flex: 0 0 4.5rem;
    font-size: 1.15rem;
}

.journal-date-arrow:hover { border-color: var(--accent); color: var(--accent); }

.journal-date-center {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.journal-date-label {
    font-size: 1.1rem;
    font-weight: 700;
}

.journal-date-input {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
}

/* ---- Carte résumé calories du jour ---- */

.journal-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.journal-kcal-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.journal-kcal-goal {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.journal-kcal-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0.6rem;
}

.journal-kcal-sub a { color: var(--accent); font-weight: 600; }

.progress-outer {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.progress-kcal { height: 14px; }

.progress-inner {
    height: 100%;
    background: var(--accent-green);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-inner.over { background: var(--accent-red); }

.journal-macros-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Chaque colonne affiche toujours 3 lignes : nom, grammes, barre.
   Les trois macros restent ainsi parfaitement alignées entre elles. */
.journal-macros-row .macro-bar {
    display: flex;
    flex-direction: column;
}

.journal-macros-row .macro-bar .progress-outer { margin-top: auto; }

.macro-bar-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.macro-bar-value {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    white-space: nowrap;
}

.journal-fibres {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Boutons d'action du journal ---- */

.journal-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.journal-add-btn {
    flex: 1;
    justify-content: center;
    min-height: 48px;
    font-size: 1rem;
}

.journal-actions .btn-secondary { min-height: 48px; }

/* ---- Repas du jour ---- */

.journal-meal-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.journal-meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 0.92rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.journal-meal-kcal {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.journal-entry {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
}

.journal-entry:last-child { border-bottom: none; }

.journal-entry-time {
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-dark);
    background: var(--accent-light);
    border-radius: 0.5rem;
    padding: 0.2rem 0.4rem;
}

.journal-entry-main { flex: 1; min-width: 0; }

.journal-entry-title {
    font-size: 0.9rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.journal-entry-qty {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.journal-entry-kcal {
    flex: 0 0 auto;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.journal-entry-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 0.15rem;
}

.entry-action {
    background: none;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 0.4rem;
    line-height: 1;
}

.entry-action:hover { background: var(--bg); }

.journal-empty { padding: 2rem 1rem; }

/* ---- Sélection de plats (copie plat par plat) ---- */

.selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: 0.85rem;
    padding: 0.6rem 0.9rem;
    margin-bottom: 0.75rem;
}

.selection-bar-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.journal-entry.selectable { cursor: pointer; }
.journal-entry.selectable:hover { background: var(--bg); }
.journal-entry.selected { background: var(--accent-light); }

.entry-check {
    flex: 0 0 auto;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entry-check.checked {
    background: var(--accent);
    border-color: var(--accent);
}

#selectModeBtn.active {
    border-color: var(--accent);
    color: var(--accent-dark);
    background: var(--accent-light);
}

.chips-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    align-self: center;
}

/* ---- Graphique 7 jours ---- */

.week-chart {
    display: flex;
    gap: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem 0.75rem 0.75rem;
    margin-bottom: 1.5rem;
}

.week-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    border-radius: 0.5rem;
    padding: 0.25rem 0.1rem;
}

.week-bar-col:hover { background: var(--bg); }

.week-bar-col.current { background: var(--accent-light); }

.week-bar-kcal {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-height: 0.9rem;
    white-space: nowrap;
}

.week-bar-track {
    position: relative;
    width: 100%;
    max-width: 34px;
    height: 90px;
    background: var(--bg);
    border-radius: 0.4rem;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.week-bar {
    width: 100%;
    border-radius: 0.4rem 0.4rem 0 0;
    background: var(--border);
    transition: height 0.3s ease;
}

.week-bar.ok { background: var(--accent-green); }
.week-bar.under { background: var(--accent-amber); }
.week-bar.over { background: var(--accent-red); }

.week-bar-goal {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dashed var(--text-muted);
    opacity: 0.7;
}

.week-bar-day {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

/* ============================================
   CALENDRIER
   ============================================ */

.cal-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.cal-month-label {
    font-size: 1.15rem;
    font-weight: 700;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.cal-weekdays span {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.cal-cell {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    min-height: 64px;
    padding: 0.3rem 0.25rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    transition: transform 0.1s ease;
}

.cal-cell:hover { transform: scale(1.04); border-color: var(--accent); }

.cal-blank { background: none; border: none; cursor: default; }
.cal-blank:hover { transform: none; }

.cal-day-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.cal-today { outline: 2px solid var(--accent); outline-offset: -1px; }

.cal-kcal {
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.cal-emojis {
    font-size: 0.7rem;
    letter-spacing: -0.05em;
    overflow: hidden;
    white-space: nowrap;
    max-width: 100%;
}

.cal-ok { background: var(--accent-green-light); border-color: var(--accent-green); }
.cal-under { background: var(--accent-amber-light); border-color: var(--accent-amber); }
.cal-over { background: var(--accent-red-light); border-color: var(--accent-red); }

.cal-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.cal-legend > span { display: inline-flex; align-items: center; gap: 0.3rem; }

.cal-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    display: inline-block;
}

.cal-dot-ok { background: var(--accent-green-light); border: 1px solid var(--accent-green); }
.cal-dot-under { background: var(--accent-amber-light); border: 1px solid var(--accent-amber); }
.cal-dot-over { background: var(--accent-red-light); border: 1px solid var(--accent-red); }

.cal-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   OBJECTIFS
   ============================================ */

.objectifs-intro {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.objectifs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.objectif-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.objectif-card-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.objectif-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.objectif-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.objectif-inputs label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.objectif-save { align-self: flex-start; }

/* Période de l'objectif (dates de début et de fin) */
.objectif-dates-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.objectif-debut-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.objectif-debut-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: -0.35rem 0 0;
}

/* Historique des périodes d'objectifs */
.objectif-histo {
    border-top: 1px solid var(--border);
    padding-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.objectif-histo-title {
    font-size: 0.85rem;
    font-weight: 700;
}

.objectif-histo-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem 0.75rem;
}

.objectif-histo-body { flex: 1; min-width: 0; }

.objectif-histo-main {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: baseline;
}

.objectif-histo-preset {
    font-size: 0.85rem;
    font-weight: 700;
}

.objectif-histo-macros {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.objectif-histo-dates {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.objectif-encours {
    color: var(--accent-green);
    font-weight: 700;
}

.objectif-avenir {
    color: var(--accent-blue);
    font-weight: 700;
}

/* Champs de dates des objectifs : iOS affiche mal un champ date vide
   (boîte flottante décalée) sans largeur et hauteur explicites. */
.objectif-dates-row label { min-width: 0; }

.objectif-dates-row input[type="date"] {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-card);
}

/* ============================================
   MODAL REPAS
   ============================================ */

.repas-datetime-row {
    display: grid;
    /* minmax(0,1fr) : les champs date/heure d'iPhone ont une largeur minimale
       imposée qui, avec un simple 1fr, fait déborder la grille du pop-up
       (d'où le tremblement gauche-droite au scroll) */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.6rem;
}

/* Chaque colonne coupe ce qui voudrait dépasser : garantie absolue
   qu'aucun champ ne sort de sa moitié */
.repas-datetime-row > div {
    min-width: 0;
    overflow: hidden;
}

/* Safari iPhone impose une largeur native aux champs date/heure tant
   qu'on ne désactive pas leur apparence système ; c'est elle qui faisait
   déborder le pop-up malgré la grille. */
.repas-datetime-row .form-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    min-height: 44px;
    text-align: center;
}

/* Une fois l'apparence système retirée, iOS écrase la hauteur du texte
   et le colle à gauche : on recentre et on redonne une hauteur normale */
.repas-datetime-row .form-input::-webkit-date-and-time-value {
    text-align: center;
    min-height: 1.3em;
}

.repas-datetime-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.repas-source-tabs {
    display: flex;
    gap: 0.4rem;
}

.repas-source-tab {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem 0.4rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    min-height: 46px;
    transition: all 0.15s ease;
}

.repas-source-tab.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent-dark);
}

.repas-source-panel { margin-bottom: 1rem; }

.repas-recette-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
}

.repas-recette-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
    min-height: 44px;
}

.repas-recette-row:last-child { border-bottom: none; }
.repas-recette-row:hover { background: var(--bg); }
.repas-recette-row.active { background: var(--accent-light); }

.repas-recette-emoji { flex: 0 0 auto; font-size: 1.1rem; }

.repas-recette-titre {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.repas-recette-kcal {
    flex: 0 0 auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.repas-recette-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.repas-qty-row { margin-top: 0.75rem; }

.repas-qty-row label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

/* ---- Open Food Facts ---- */

.off-scan-btn {
    width: 100%;
    justify-content: center;
    min-height: 50px;
    font-size: 1rem;
    margin-bottom: 0.6rem;
}

.scanner-wrap {
    margin-bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

/* Fenêtre caméra large et peu haute (2:1) : adaptée à un code-barres,
   et bien moins encombrante qu'une vidéo plein format.
   Mêmes règles pour les 3 scanners : repas, aliment, ingrédient. */
#scannerBox, #alimScanBox, #compoScanBox {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 2 / 1;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
    position: relative;
}

#scannerBox video, #alimScanBox video, #compoScanBox video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Ligne de visée : on aligne le code-barres dessus */
#scannerBox::after, #alimScanBox::after, #compoScanBox::after {
    content: '';
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: rgba(255, 70, 70, 0.85);
    border-radius: 2px;
    pointer-events: none;
}

.off-input-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.off-input-row .form-input { flex: 1; }

.off-status {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-height: 1.1rem;
    margin-bottom: 0.4rem;
}

.off-results {
    display: flex;
    flex-direction: column;
    border-radius: 0.75rem;
    overflow: hidden;
}

.off-results .repas-recette-row { border: 1px solid var(--border); border-bottom: none; }
.off-results .repas-recette-row:last-child { border-bottom: 1px solid var(--border); }

.off-product {
    background: var(--accent-light);
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    margin-top: 0.5rem;
}

.off-product-name {
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 0.25rem;
}

.off-product-per100 {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Aperçu macros du repas ---- */

.repas-preview {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    min-height: 3rem;
    align-items: center;
}

.repas-preview-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ---- Modal copier un jour ---- */

.copy-day-modal { max-width: 460px; }

.copy-day-source {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ---- Navigation des onglets : liste déroulante sur mobile ---- */

/* Cachée sur ordinateur (les onglets classiques restent) */
.tabs-select-wrap { display: none; }

.tabs-select {
    width: 100%;
    min-height: 48px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-dark);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.5rem 2.4rem 0.5rem 1rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    /* Petite flèche ▾ pour montrer que ça se déroule */
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c3aed' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
}

@media (max-width: 720px) {
    .tabs-nav .tabs-inner { display: none; }
    .tabs-select-wrap { display: block; padding: 0.6rem 1rem; }
}

/* ---- Mobile ---- */

@media (max-width: 720px) {
    /* Anti-zoom iOS : Safari zoome toute la page quand on touche un champ
       dont la police fait moins de 16px — c'est ce qui rendait la liste des
       recettes "géante" dans le modal d'ajout de repas. */
    .modal .form-input, .modal select { font-size: 16px; }

    /* Modals de la cuisine en PLEIN ÉCRAN sur mobile : plus de place, plus
       stable (rien ne "flotte" quand le clavier ou un sélecteur s'ouvre),
       et le titre avec le X ainsi que les boutons Annuler/Enregistrer
       restent fixes pendant que seul le contenu défile. */
    .modal-overlay { padding: 0; align-items: stretch; justify-content: stretch; }

    .modal-overlay .cuisine-modal {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .cuisine-modal .modal-header {
        flex: 0 0 auto;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
    }

    .cuisine-modal .modal-header .modal-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.6rem;
    }

    .cuisine-modal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .cuisine-modal .modal-footer {
        flex: 0 0 auto;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    /* Liste des recettes du modal repas : compacte et lisible.
       Le modal étant plein écran, on lui laisse plus de hauteur. */
    .repas-recette-list { max-height: 45dvh; }
    .repas-recette-row { font-size: 0.8rem; padding: 0.5rem 0.6rem; min-height: 40px; gap: 0.4rem; }
    .repas-recette-emoji { font-size: 1rem; }
    .repas-recette-kcal { font-size: 0.62rem; }

    .journal-macros-row { gap: 0.5rem; }
    .macro-bar-label { font-size: 0.66rem; }
    .macro-bar-value { font-size: 0.72rem; }
    .journal-kcal-value { font-size: 1.7rem; }
    .cal-cell { min-height: 58px; padding: 0.25rem 0.15rem; border-radius: 0.5rem; }
    .cal-kcal { font-size: 0.62rem; }
    .cuisine-filter-select { min-width: 0; }
    .journal-actions { flex-direction: row; }
    .journal-entry { padding: 0.65rem 0.6rem; }
    .journal-entry-actions .entry-action { min-width: 34px; min-height: 34px; }
    .objectifs-cards { grid-template-columns: 1fr; }
    .repas-datetime-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .week-bar-kcal { font-size: 0.56rem; }
}

@media (max-width: 720px) {
    .cuisine-main { padding: 1rem; }
    .cuisine-grid { grid-template-columns: 1fr; }
    .cuisine-detail { padding: 1.1rem; }
    .cuisine-detail-title { font-size: 1.15rem; }
    .page-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .page-header .btn-primary { justify-content: center; min-height: 48px; }
    .cuisine-macros-table { font-size: 0.85rem; }
    .cuisine-modal { width: calc(100% - 1rem); max-height: 92vh; }

    /* Étapes : plus grandes et aérées sur mobile pour cuisiner téléphone en main */
    .cuisine-etape-item { padding: 0.9rem 0.9rem; }
    .cuisine-etape-text { font-size: 1.02rem; line-height: 1.65; }
    .cuisine-add-etape { width: 100%; justify-content: center; min-height: 44px; }
}

/* ============================================
   ALIMENTS — Notre base perso (onglet + modal)
   ============================================ */

.aliments-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

.aliment-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.aliment-card:hover { border-color: var(--accent); }

.aliment-emoji { font-size: 1.5rem; flex-shrink: 0; }

.aliment-main { flex: 1; min-width: 0; }

.aliment-titre {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 0.3rem;
    overflow-wrap: anywhere;
}

.aliment-marque {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.aliment-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.aliment-actions { flex-shrink: 0; }

/* Sections des résultats de recherche (Notre base / CIQUAL / OFF) */
.off-results-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.55rem 0.25rem 0.25rem;
}

.off-create-row { margin: 0.5rem 0; }
.off-create-row .btn-primary { width: 100%; justify-content: center; }

/* Composition d'un aliment (liste d'ingrédients) */
.compo-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.75rem; }

.compo-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
}

.compo-item-nom { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.compo-item-qty { width: 74px; flex-shrink: 0; text-align: right; padding: 0.3rem 0.4rem; }
.compo-item-kcal { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; white-space: nowrap; }

.compo-add-zone label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.compo-pick-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    background: var(--accent-light);
    border-radius: 0.6rem;
    padding: 0.5rem 0.6rem;
}

.compo-pick-name { flex: 1; min-width: 0; font-size: 0.85rem; font-weight: 600; overflow-wrap: anywhere; }
.compo-pick-qty { width: 80px; flex-shrink: 0; text-align: right; }

.compo-totals {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 0.6rem;
    font-size: 0.85rem;
    line-height: 1.6;
}

.compo-totals:empty { display: none; }

.compo-empty { padding: 0.4rem 0.2rem; }

/* ============================================
   FAVORIS ❤️ + badges de source
   ============================================ */

/* Bouton "❤️ +" à côté d'Ajouter un repas : compact, on sait ce que c'est */
.fav-add-btn { flex: 0 0 auto; white-space: nowrap; }

/* Petit badge "d'où viennent les macros" dans la timeline */
.entry-source {
    color: var(--text-muted);
    font-size: 0.68rem;
    white-space: nowrap;
}

/* Coeur d'un plat du journal */
.entry-fav.is-fav { opacity: 1; }

/* Source dans le panneau produit du modal repas */
.off-product-source {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

/* Liste des favoris dans le modal */
.fav-list .fav-row { position: relative; }
.fav-source {
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    margin-top: 0.1rem;
}
.fav-del { flex-shrink: 0; }
.fav-empty { padding: 1.2rem 0.8rem; }

/* ============================================
   JOURNAL — nouvelle mise en page des repas
   (ligne 1 : heure + titre · ligne 2 : quantité/source ·
    ligne 3 : kcal + macros + boutons)
   ============================================ */

.journal-entry { align-items: flex-start; }

.journal-entry-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.journal-entry-line1 {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.journal-entry-line1 .journal-entry-time { margin-top: 0.1rem; }
.journal-entry-line1 .journal-entry-title { flex: 1; min-width: 0; }

.journal-entry-line2 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.7rem;
}

.entry-macros {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.journal-entry-line2 .journal-entry-actions { margin-left: auto; }

/* Coeur favori sur les cartes de recettes (à gauche du numéro #01) */
.rec-fav {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    background: none;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.4rem;
    line-height: 1;
    z-index: 1;
}

.rec-fav:hover { background: var(--bg); }
.rec-fav-decale { right: 3.6rem; }

/* Colonne heure façon timeline : le badge en haut, un trait-guide dessous,
   et tout le contenu du plat aligné à droite de l'heure */
.journal-entry-timecol {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: stretch;
    gap: 0.35rem;
}

.journal-entry-guide {
    flex: 1;
    width: 2px;
    min-height: 0.4rem;
    border-radius: 2px;
    background: var(--border);
}
