@font-face {
  font-family: "Comfortaa"; font-weight: 300; font-style: normal; font-display: swap;
  src: url("../fonts/Comfortaa-Light.ttf") format("truetype");
}
@font-face {
  font-family: "Comfortaa"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/Comfortaa-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Comfortaa"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/Comfortaa-Bold.ttf") format("truetype");
}
/* Menu imprimé (polices du fichier Word du restaurant) */
@font-face {
  font-family: "Susurrus BB"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/SusurrusBB-Regular.otf") format("opentype");
}
@font-face {
  font-family: "Susurrus BB"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/SusurrusBB-Bold.otf") format("opentype");
}
@font-face {
  font-family: "Susurrus BB"; font-weight: 700; font-style: italic; font-display: swap;
  src: url("../fonts/SusurrusBB-BoldItalic.otf") format("opentype");
}
@font-face {
  font-family: "Bitcheese"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/Bitcheese.ttf") format("truetype");
}
:root {
  --navy: #092849;
  --red: #A50020;
  --cream: #FFF9EF;
  --white: #FFFFFF;
  --ink: #202020;
  --line: #e4dccd;
  --muted: #6b6457;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Roboto Condensed", system-ui, sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: var(--cream);
}
h1, h2 { color: var(--navy); margin: 0 0 .6em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
.kaushan, .script { font-family: "Kaushan Script", cursive; color: var(--red); font-weight: 400; }
.courgette { font-family: "Courgette", cursive; color: var(--red); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
a { color: var(--red); }

/* Barre du haut */
.topbar {
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; gap: 8px 20px;
  padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  padding-top: max(10px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 3px 14px rgba(9, 40, 73, .32);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: "Kaushan Script", cursive; color: var(--white); text-decoration: none; font-size: 1.4rem; margin-right: auto; }
.brand img { height: 40px; width: auto; display: block; }
.brand em { font-style: normal; color: #ff8fa1; }
.login-logo { display: block; width: 160px; height: auto; margin: 0 auto 6px; }
.tabs { display: flex; gap: 4px 14px; align-items: center; }
.tabs a, .topbar .link {
  display: flex; align-items: center; gap: 6px;
  color: #d6dde8; text-decoration: none; padding: 6px 4px; border-bottom: 2px solid transparent;
  font: inherit; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer;
}
.tabs a.on, .tabs a:hover, .topbar .link:hover { color: var(--white); border-bottom-color: var(--red); }
.topbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tabs svg { display: none; }
.top-account { display: none !important; }
form.inline { display: inline; margin: 0; }

/* Mise en page */
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 60px; }
.page.narrow { max-width: 440px; }
.login { padding-top: 10vh; }
.login h1 { text-align: center; font-size: 2.6rem; margin-bottom: 0; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 1px 2px rgba(9, 40, 73, .05);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.span2 { grid-column: 1 / -1; }
/* Administration : sous-onglets */
.admin-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 0 0 18px; }
.admin-tabs a { padding: 10px 16px; color: var(--muted); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.admin-tabs a:hover { color: var(--navy); }
.admin-tabs a.on { color: var(--navy); border-bottom-color: var(--red); }

/* Fonctionnalités (admin) */
.feat-form { max-width: 760px; }
.feat-list h2 { margin-top: 0; }
.feat { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); margin: 0; cursor: pointer; }
.feat-list h2 + .feat { border-top: 0; }
.feat-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feat-text strong { color: var(--navy); }
.feat.nested { margin-left: 22px; padding-left: 14px; border-left: 3px solid var(--line); }
.feat.disabled { opacity: .5; cursor: default; }
.feat-note { margin: 8px 0 0; }
.toggle { position: relative; flex: none; width: 52px; height: 30px; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; border-radius: 999px; background: #cfc6b5; transition: background .2s; pointer-events: none; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + .track { background: #2f7d3a; }
.toggle input:checked + .track::after { transform: translateX(22px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--navy); outline-offset: 2px; }
.toggle input:disabled + .track { cursor: default; }
.closed-note { color: var(--muted); }

/* Épicerie fine */
.page-head + .epi-source { margin-top: -6px; }
.warn-text { color: #a35a00; }
.epi-cats { flex-wrap: wrap; }
.epi-cats button span { opacity: .6; font-weight: 400; margin-left: 2px; }
.epi-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.epi-view svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; margin-right: 2px; }
.epi-grid .epi-desc { display: none; }
/* Affichage liste : vignette, nom, description, prix */
.epi-list { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.epi-list .epi-card { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 14px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; transform: none; background: transparent; }
.epi-list .epi-card:last-child { border-bottom: 0; }
.epi-list .epi-card:hover { box-shadow: none; transform: none; background: #fbf8f2; }
.epi-list .epi-card .thumb { width: 84px; height: 112px; aspect-ratio: auto; border-radius: 6px; overflow: hidden; background: #f1ebdf; }
.epi-list .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.epi-list .badge-off { top: 4px; left: 4px; font-size: .68rem; padding: 2px 6px; }
.epi-list .epi-card .info { padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cat bottom" "name bottom" "qty bottom" "desc bottom"; grid-template-rows: auto auto auto 1fr; column-gap: 16px; row-gap: 2px; align-items: start; }
.epi-list .epi-card .cat { grid-area: cat; }
.epi-list .epi-card strong { grid-area: name; font-size: 1.05rem; }
.epi-list .epi-card .epi-qty { grid-area: qty; }
.epi-list .epi-card .epi-desc { grid-area: desc; margin: 6px 0 0; white-space: pre-line; color: #4a4438; font-size: .92rem; line-height: 1.4; }
.epi-list .epi-card .epi-bottom { grid-area: bottom; flex-direction: column; align-items: flex-end; gap: 4px; margin: 0; }
.epi-list .epi-price { font-size: 1.1rem; }
.epi-card .thumb { position: relative; display: block; }
.epi-card .no-photo { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .9rem; }
.epi-card.off .thumb img { opacity: .45; filter: grayscale(.6); }
.epi-card.off strong { color: var(--muted); }
.badge-off { position: absolute; top: 8px; left: 8px; background: var(--navy); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.epi-card .cat { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--red); font-weight: 700; }
.epi-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.epi-bottom .tools { margin-right: -6px; }
.epi-price { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.tag.warn { background: #fff0d9; color: #8a4b00; }
.flash-target { outline: 3px solid transparent; outline-offset: -3px; animation: flash-target 2.2s ease-out; }
@keyframes flash-target { 0%, 45% { outline-color: var(--red); } 100% { outline-color: transparent; } }
.epi-form { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
.epi-photo { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.epi-photo img { width: 100%; height: auto; border-radius: 6px; display: block; }
.epi-file { position: relative; overflow: hidden; }
.epi-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.epi-fields { display: flex; flex-direction: column; gap: 4px; }
.epi-fields textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.epi-internal { margin: 6px 0 10px; }
.epi-internal summary { cursor: pointer; color: var(--muted); font-weight: 700; padding: 4px 0; }
.buttons.end { justify-content: flex-end; }

/* Menu imprimé */
.menu-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.menu-head h1 { margin: 0; }
.menu-actions { margin: 16px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 28px; align-items: start; }
.menu-actions .archive label { margin: 0 0 6px; font-weight: 700; }
.archive-row { display: flex; gap: 8px; }
.archive-row input { margin: 0; flex: 1; min-width: 0; }
.archive p { margin: 6px 0 0; }
.menu-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; margin: 18px 0 26px; }
.menu-page { margin: 0; }
.menu-page canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 2px 14px rgba(9, 40, 73, .18); border-radius: 2px; }
.menu-page.overflow canvas { outline: 3px solid var(--red); outline-offset: 3px; }
.menu-page figcaption { text-align: center; margin-top: 8px; font-size: .9rem; color: var(--muted); font-weight: 700; }
.menu-page.overflow figcaption { color: var(--red); }
.page-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 12px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--navy); text-decoration: none; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; }
.chip .num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 999px; background: #efe9dd; font-size: .8rem; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.on .num { background: rgba(255, 255, 255, .18); }
.chip.off { opacity: .55; text-decoration: line-through; }
.chip.add { color: var(--red); border-style: dashed; }
.menu-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.menu-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.menu-main .card { margin: 0; }
.menu-aside-inner { position: sticky; top: 84px; }
.menu-aside #toggle-preview { display: none; }
.page-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-header-form label { margin: 0 0 6px; font-weight: 700; }
.page-header-form .row { display: flex; gap: 8px; }
.page-header-form select { margin: 0; min-width: 200px; }
.page-bar .page-off { width: 100%; margin: 0; }
.cover-note { margin: 0; }
.msec.off > *:not(.msec-head) { opacity: .5; }
.msec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.msec-title { min-width: 0; }
.msec-title h2 { margin: 0; font-family: "Courgette", cursive; font-weight: 400; color: var(--red); font-size: 1.3rem; }
.msec-title p { margin: 2px 0 8px; }
.msec-head .tools { flex: none; }
.section-form, .menu-item-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; margin: 6px 0 14px; padding: 14px; background: #f7f3ea; border-radius: 10px; }
.section-form label, .menu-item-form label { margin: 0; font-size: .85rem; }
.section-form label input, .section-form label select, .section-form label textarea,
.menu-item-form label input { margin-top: 4px; }
.section-form .f-wide, .menu-item-form .f-wide, .section-form .f-actions, .menu-item-form .f-actions, .menu-item-form .f-prices { grid-column: 1 / -1; }
.section-form .check, .menu-item-form .check { align-self: center; font-size: .95rem; }
.section-form textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.menu-item-form .f-prices { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.menu-item-form .f-prices input { text-align: right; }
.menu-item-form .f-actions, .section-form .f-actions { display: flex; justify-content: flex-end; gap: 8px; }
.item.editing .menu-item-form { margin: 0; background: transparent; padding: 0; }
.add-line { margin-top: 10px; }
.add-line summary { cursor: pointer; color: var(--red); font-weight: 700; padding: 6px 0; list-style: none; }
.add-line summary::-webkit-details-marker { display: none; }
.add-line summary::before { content: "+ "; }
.add-line[open] summary { margin-bottom: 4px; }
.multi-prices { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: .85rem; font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.multi-prices em { font-style: normal; color: var(--muted); font-weight: 400; }
.tag.veg { background: #e3f1e0; color: #2f6b2a; }
.body-preview { margin: 0; color: var(--muted); }
.add-section { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.add-section .add-title { grid-column: 1 / -1; margin: 0; font-weight: 700; }
.add-section select, .add-section input { margin: 0; }
.versions h2 { margin-top: 0; }
.version-list { list-style: none; margin: 0; padding: 0; }
.version-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.version-list li:last-child { border-bottom: 0; }
.v-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.v-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* Formulaires */
label { display: block; margin: 0 0 12px; font-weight: 500; color: var(--navy); }
label .courgette { font-size: 1.15rem; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--white);
  border: 1px solid #cfc6b5; border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }
input.invalid { border-color: var(--red); background: #fff1f3; }
input.price { text-align: right; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--navy);
  background: var(--white); color: var(--navy); font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #eef2f7; }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.primary:hover { background: #8a001b; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .6; cursor: wait; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.flash { padding: 12px 16px; border-radius: 8px; margin: 0 0 12px; border-left: 5px solid; background: var(--white); }
.flash.error { border-color: var(--red); background: #fff1f3; color: #6d0015; }
.flash.warning { border-color: #d48a00; background: #fff8e6; color: #5c3d00; }
.flash.success { border-color: #2e7d32; background: #eef8ef; color: #1b4d1e; }
#messages { margin-top: 18px; }

/* Générateur */
.dish-grid { display: grid; grid-template-columns: 1fr 100px; gap: 8px 10px; }
.dish-grid input { margin: 0; }
.dish-grid .head { font-weight: 700; color: var(--navy); font-size: .9rem; }
.badge { display: inline-block; background: var(--navy); color: var(--white); font-family: "Roboto Condensed", sans-serif;
  font-weight: 700; font-size: .95rem; border-radius: 999px; padding: 2px 12px; vertical-align: middle; }
.options { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; }
label.check { display: flex; align-items: center; gap: 10px; margin: 0; flex-wrap: wrap; }
label.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--red); }
#results, #messages { margin-top: 26px; scroll-margin-top: 80px; }
.results-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.results-head h2 { margin: 0; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.preview { margin: 0; padding: 12px; min-width: 0; }
.preview img { width: 100%; height: auto; display: block; border-radius: 6px; }
/* Choix du format d'export */
.format-switch { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line, #d9d2c4); border-radius: 999px; padding: 3px; background: #fff; }
.format-switch > span { padding: 0 8px 0 10px; font-size: .85rem; color: var(--muted); }
.format-switch label { margin: 0; cursor: pointer; }
.format-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.format-switch label span { display: block; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; color: var(--navy); }
.format-switch input:checked + span { background: var(--navy); color: #fff; }
.format-switch input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.gen-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.soiree-gen .preview { padding: 0; margin-top: 16px; }
.soiree-gen #results { margin-top: 0; }
.soiree-gen .all-bar { justify-content: flex-end; margin-top: 16px; }
.soiree-previews .preview + .preview { padding-top: 16px; border-top: 1px solid var(--line); }
.preview figcaption { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-weight: 700; color: var(--navy); }

/* Ardoise */
.items { list-style: none; margin: 0 0 8px; padding: 0; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start;
  gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.item .main { min-width: 0; padding-top: 6px; }
.item .name { display: block; font-weight: 700; color: var(--navy); line-height: 1.25; }
.item .details { display: block; font-size: .9rem; color: var(--muted); margin-top: 3px; line-height: 1.3; }
.item .price { white-space: nowrap; font-weight: 700; color: var(--red); padding-top: 6px; font-variant-numeric: tabular-nums; }
.item.off .name, .item.off .details, .item.off .price { opacity: .45; }
.item.off .name .tag { opacity: 1; }
.tools { display: flex; margin: 0; }
.icon {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: 8px; cursor: pointer; color: #7d8696; padding: 0;
}
.icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover:not(:disabled) { background: #eef2f7; color: var(--navy); }
.icon.danger:hover:not(:disabled) { background: #fff1f3; color: var(--red); }
.icon:disabled { opacity: .25; cursor: default; }

.item-form { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; margin: 0; }
.item-form label { margin: 0; font-size: .85rem; }
.item-form .f-details, .item-form .f-actions, .item-form .add-title { grid-column: 1 / -1; }
.item-form .f-price input { text-align: right; }
.item-form .f-actions { display: flex; justify-content: flex-end; gap: 8px; }
.item.editing { display: block; background: #f7f3ea; margin: 0 -12px; padding: 14px 12px; border-radius: 10px; border-bottom: 0; }
.item-form.add { margin-top: 14px; padding-top: 14px; }
.add-title { margin: 0; font-weight: 700; color: var(--navy); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.split-setting { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 18px; padding: 14px 18px; }
.split-setting label { margin: 0; }
.split-setting input { width: 76px; margin: 0; text-align: center; }
.split-setting p { flex-basis: 100%; margin: 2px 0 0; }

/* Bibliothèque */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.btn svg, .lib-search svg, .drop svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.crumb { margin: 0 0 8px; }
.crumb a { text-decoration: none; font-weight: 500; }
.lib-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px; margin-bottom: 10px; }
.lib-search { position: relative; flex: 1 1 260px; margin: 0; }
.lib-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.lib-search input { margin: 0; padding-left: 38px; }
.seg { display: inline-flex; border: 1px solid #cfc6b5; border-radius: 9px; overflow: hidden; background: var(--white); }
.seg button, .seg label span { display: block; border: 0; background: none; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--navy); cursor: pointer; white-space: nowrap; }
.seg button + button, .seg label + label span { border-left: 1px solid #cfc6b5; }
.seg button.on, .seg input:checked + span { background: var(--navy); color: var(--white); }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--red); outline-offset: -3px; }
.lib-dates { display: flex; gap: 8px; align-items: center; }
.lib-dates label, .lib-sort { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.lib-dates input, .lib-sort select { margin: 0; width: auto; padding: 8px 10px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.lib-card { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--ink); transition: box-shadow .15s, transform .15s; }
.lib-card:hover { box-shadow: 0 6px 20px rgba(9, 40, 73, .14); transform: translateY(-2px); }
.lib-card .thumb { aspect-ratio: 3 / 4; background: #f1ebdf; overflow: hidden; }
.lib-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.lib-card strong { color: var(--navy); line-height: 1.25; }
.when { color: var(--muted); font-size: .88rem; }
.kind { align-self: flex-start; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.kind-evenement { background: #fde8ec; color: var(--red); }
.kind-creation { background: #e6edf6; color: var(--navy); }
.kw { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.kw span { font-size: .78rem; background: #f4efe5; color: #5d564a; padding: 2px 8px; border-radius: 999px; }
.lib-card .kw span:hover { background: var(--navy); color: var(--white); }
.empty { text-align: center; padding: 30px 20px; }
.empty p { margin: 0 0 12px; }

.lib-form { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
.drop { display: flex; align-items: center; justify-content: center; position: relative; min-height: 320px; margin: 0;
  border: 2px dashed #cfc6b5; border-radius: 10px; background: #fbf8f2; cursor: pointer; text-align: center; overflow: hidden; }
.drop.over { border-color: var(--red); background: #fff1f3; }
.drop.has-file { border-style: solid; min-height: 0; background: #f1ebdf; }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-hint { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--navy); padding: 20px; pointer-events: none; }
.drop-hint svg { width: 36px; height: 36px; }
.lib-preview { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; border-radius: 6px; }
.scan-status { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: .92rem; display: flex; gap: 8px; align-items: center; }
.scan-status.busy { background: #eef2f7; color: var(--navy); }
.scan-status.ok { background: #eef8ef; color: #1b4d1e; }
.scan-status.warn { background: #fff8e6; color: #5c3d00; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
input.prefilled, textarea.prefilled { background: #f3f8ff; border-color: #9fb6d6; }
textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; border: 1px solid #cfc6b5; border-radius: 8px; resize: vertical; }
textarea:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
fieldset.seg-field { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.seg-field legend { font-weight: 500; color: var(--navy); margin-bottom: 6px; padding: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.lib-detail { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 18px; align-items: start; }
.lib-full { padding: 10px; display: block; }
.lib-full img { width: 100%; height: auto; display: block; border-radius: 6px; }
.lib-meta h1 { margin: 8px 0 4px; }
.lib-meta .when { font-size: 1rem; margin: 0 0 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; margin: 14px 0 18px; color: var(--muted); }
.facts dt { font-weight: 700; color: var(--navy); }
.facts dd { margin: 0; }
.tag.lib { background: #e6edf6; }

/* Utilisateurs */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: .9rem; }
.table tr.off td { opacity: .5; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: #eef2f7; color: var(--navy); }
.tag.warn { background: #fff1f3; color: var(--red); }
.actions { text-align: right; }
details.menu { position: relative; display: inline-block; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: 110%; z-index: 4; width: 260px; text-align: left;
  background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  box-shadow: 0 8px 24px rgba(9, 40, 73, .15);
}
.menu-body form + form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.menu-body .row { display: flex; gap: 6px; flex-wrap: wrap; }


/* ------------------------------------------------------------------ */
/* Smartphone                                                          */
/* ------------------------------------------------------------------ */
:root { --tabbar: 62px; }
button, a, input, select, label { -webkit-tap-highlight-color: rgba(165, 0, 32, .15); }
button, .btn, .icon, .tabs a { touch-action: manipulation; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 1.4rem; }
  .page { padding: 16px max(12px, env(safe-area-inset-left)) 32px; }
  body.has-tabs .page { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px); }
  .card { padding: 16px; }
  .grid2 { gap: 12px; }

  /* En-tête compact */
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .brand { font-size: 1.2rem; }
  .brand img { height: 34px; }
  .topbar .logout span { display: none; }
  .topbar .logout .link { padding: 8px; border: 0; }
  .topbar .logout svg { width: 24px; height: 24px; }

  /* Onglets en bas de l'écran */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--navy); gap: 0; justify-content: space-around;
    padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -2px 12px rgba(9, 40, 73, .25);
  }
  .tabs a {
    flex: 1; flex-direction: column; gap: 2px; min-height: 54px; justify-content: center;
    font-size: .74rem; padding: 4px 2px; border: 0; border-top: 3px solid transparent; max-width: 120px;
  }
  .tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs a.on { border-top-color: var(--red); background: rgba(255, 255, 255, .06); }
  .tabs svg { display: block; width: 24px; height: 24px; }

  /* Champs : 16px minimum (pas de zoom automatique sur iPhone), cibles tactiles 44px */
  input, select { font-size: 16px; min-height: 46px; }
  .btn { min-height: 46px; }
  .btn.small { min-height: 40px; padding: 8px 14px; }

  /* Générateur */
  .dish-grid { grid-template-columns: 1fr 86px; gap: 8px; }
  .options {
    position: sticky; z-index: 10;
    bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px);
    box-shadow: 0 6px 24px rgba(9, 40, 73, .22); padding: 12px 14px;
  }
  .options { gap: 10px; }
  .options label.check { font-size: .95rem; flex-wrap: nowrap; }
  .options label.check a { display: none; }
  .options .buttons { width: 100%; }
  .options .buttons .btn { flex: 1; }
  .options .buttons #btn-clear { flex: 0 0 auto; }
  .results-head .buttons { width: 100%; }
  .results-head .buttons .btn { flex: 1; }
  .previews { grid-template-columns: minmax(0, 1fr); }
  .preview figcaption { flex-wrap: wrap; }
  .preview figcaption span { width: 100%; }
  .preview figcaption .btn { flex: 1; }

  /* Ardoise */


  .item { grid-template-columns: minmax(0, 1fr) auto; }
  .item .tools { grid-column: 1 / -1; justify-content: flex-end; margin-right: -8px; }
  .icon { width: 44px; height: 40px; }
  .icon svg { width: 21px; height: 21px; }
  .item-form { grid-template-columns: minmax(0, 1fr) 96px; }
  .item-form .f-actions .btn { flex: 1; }

  /* Bibliothèque */
  .lib-filters { padding: 12px; }
  .lib-search { flex-basis: 100%; }
  .seg { width: 100%; }
  .seg button, .seg label { flex: 1; text-align: center; }
  .seg button { padding: 10px 6px; }
  .lib-dates { width: 100%; }
  .lib-dates label { flex: 1 1 0; min-width: 0; }
  .lib-dates input { flex: 1 1 0; min-width: 0; width: 100%; padding: 8px 6px; font-size: 15px; }
  .lib-sort { width: 100%; }
  .lib-sort select { flex: 1; }
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lib-card .info { padding: 8px 10px 10px; }
  .lib-card .kw { display: none; }
  .lib-form, .lib-detail { grid-template-columns: minmax(0, 1fr); }
  .drop { min-height: 200px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .form-actions .btn { flex: 1 1 100%; }
  .page-head .btn { flex: 1 1 100%; }

  /* Utilisateurs : tableau en cartes */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
  .table td { border: 0; padding: 0; }
  .table td:nth-child(2), .table td:nth-child(3) { grid-column: 1; color: var(--muted); font-size: .9rem; }
  .table td.actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  details.menu[open] { position: static; }
  details.menu[open] .menu-body { position: fixed; left: 12px; right: 12px; top: auto;
    bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px); width: auto; z-index: 40; }

  /* Connexion */
  .login { padding-top: max(6vh, env(safe-area-inset-top)); }
  .login-logo { width: 130px; }
}

@media (max-width: 960px) {
  .menu-editor { grid-template-columns: minmax(0, 1fr); }
  .menu-aside { order: -1; }
  .menu-aside-inner { position: static; }
  .menu-aside #toggle-preview { display: inline-flex; width: 100%; }
  .menu-aside #page-preview { display: none; max-width: 420px; margin: 12px auto 0; }
  .menu-aside.open #page-preview { display: block; }
}
@media (max-width: 760px) {
  .menu-actions { grid-template-columns: minmax(0, 1fr); }
  .menu-actions .buttons .btn { flex: 1; }
  .section-form, .menu-item-form { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .msec-head { flex-direction: column; }
  .msec-head .tools { align-self: flex-end; margin-top: -4px; }
  .add-section { grid-template-columns: minmax(0, 1fr); }
  .page-header-form, .page-header-form select { width: 100%; min-width: 0; }
  .menu-pages { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .epi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .epi-list .epi-card { grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .epi-list .epi-card .thumb { width: 64px; height: 86px; }
  .epi-list .epi-card .info { grid-template-columns: minmax(0, 1fr); grid-template-areas: "cat" "name" "qty" "desc" "bottom"; grid-template-rows: none; }
  .epi-list .epi-card .epi-bottom { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 6px; }
  .epi-list .epi-card .epi-bottom .tools { width: auto; margin: 0 -6px 0 0; }
  .epi-view { flex: none; }
  .epi-card .info { padding: 8px 10px 10px; }
  .epi-card strong { font-size: .95rem; }
  .epi-bottom { flex-wrap: wrap; }
  .epi-bottom .tools { width: 100%; justify-content: space-between; margin: 0 -6px; }
  .epi-cats { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .epi-cats button { flex: none; }
  .epi-form, .row2 { grid-template-columns: minmax(0, 1fr); }
  .epi-photo img { max-height: 40vh; object-fit: contain; }
  .epi-photo { order: 2; }  /* champs (prix…) d'abord sur smartphone */
}

@media (max-width: 760px) {
  /* Compte en haut à droite : libère une place dans la barre d'onglets */
  .tabs a.tab-account { display: none; }
  .topbar .top-account { display: flex !important; padding: 8px; border: 0; color: #d6dde8; }
  .topbar .top-account svg { width: 24px; height: 24px; }
}
