/* ── Variables & Reset ───────────────────────────────────────────── */
:root {
  --primary:      #e05c3a;
  --primary-dark: #c04a2a;
  --surface:      #ffffff;
  --surface-2:    #f7f5f2;
  --border:       #e8e4df;
  --text:         #1a1a1a;
  --text-muted:   #6b6560;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10);
  --radius:       10px;
  --radius-lg:    16px;
  --transition:   .18s ease;
  --max-width:    1200px;
  --header-h:     60px;
}

/* ── Mode sombre ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --surface:   #1e1e2e;
  --surface-2: #181825;
  --border:    #313244;
  --text:      #cdd6f4;
  --text-muted:#a6adc8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,.5);
}
[data-theme="dark"] .ocr-raw { background: #11111b; }
[data-theme="dark"] .card-img-placeholder,
[data-theme="dark"] .detail-hero-placeholder { background: linear-gradient(135deg,#313244,#1e1e2e); }
[data-theme="dark"] .ingredients-list li { border-left-color: var(--primary); }

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

html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--surface-2);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; border: none; }
input, select, textarea { font: inherit; }

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}
.logo-icon { font-size: 1.4rem; }

.nav { display: flex; gap: .5rem; }

.nav-link {
  padding: .4rem .9rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
}
.nav-link:hover, .nav-link.active {
  background: var(--surface-2);
  color: var(--primary);
}

/* ── Views ───────────────────────────────────────────────────────── */
.view { display: none; padding-top: 2rem; padding-bottom: 4rem; }
.view.active { display: block; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  font-size: .9rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition), transform .1s;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ── Form controls ───────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(224,92,58,.15);
}
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6560' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

/* ── Filters bar ─────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}
.search-wrap {
  display: flex;
  gap: .5rem;
  flex: 1 1 280px;
  min-width: 0;
}
.search-wrap .input { flex: 1; min-width: 0; }
.filters {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.filters .input { width: auto; min-width: 140px; }

.clear-filters-btn {
  color: var(--primary);
  border-color: var(--primary);
  font-size: .82rem;
  padding: .45rem .8rem;
  white-space: nowrap;
}
.clear-filters-btn:hover { background: #fdf5f2; }

.results-count {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Recipe grid ─────────────────────────────────────────────────── */
.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.25rem;
}

.recipe-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Bouton favori sur les cartes ────────────────────────────────── */
.fav-btn {
  position: absolute;
  top: .6rem;
  right: .6rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #e8e0d8;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0a090;
  box-shadow: 0 2px 6px rgba(0,0,0,.13);
  transition: transform .15s, color .15s, border-color .15s, box-shadow .15s;
  z-index: 2;
  line-height: 1;
}
[data-theme="dark"] .fav-btn { background: #2a2a3e; border-color: #444; color: #888; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.fav-btn:hover { transform: scale(1.18); box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.fav-btn.fav-active { color: #f59e0b; border-color: #f59e0b; box-shadow: 0 2px 8px rgba(245,158,11,.3); }

/* ── Filtre favoris ──────────────────────────────────────────────── */
.fav-filter-btn {
  font-size: .9rem;
  font-weight: 600;
  padding: .55rem .9rem;
  border-radius: 20px;
  border: 1.5px solid #fcd34d;
  background: #fefce8;
  color: #92400e;
  white-space: nowrap;
  transition: background var(--transition), box-shadow var(--transition);
}
.fav-filter-btn:hover { background: #fef9c3; box-shadow: 0 2px 8px rgba(245,158,11,.2); }
.fav-filter-btn.fav-filter-active { background: #fef08a; border-color: #f59e0b; color: #78350f; }
[data-theme="dark"] .fav-filter-btn { background: #3d3000; border-color: #fcd34d; color: #fcd34d; }
[data-theme="dark"] .fav-filter-btn.fav-filter-active { background: #4d3d00; }
.recipe-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.card-img {
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface-2);
}
.card-img-placeholder {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #f0ebe5, #e8dfd5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.card-category {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--primary);
}
.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}
.card-desc {
  font-size: .85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin-top: auto;
  padding-top: .6rem;
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--text-muted);
}
.meta-item { display: flex; align-items: center; gap: .25rem; }

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-facile    { background: #dcfce7; color: #166534; }
.badge-moyen     { background: #fef9c3; color: #854d0e; }
.badge-difficile { background: #fee2e2; color: #991b1b; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; }

/* ── Loader ──────────────────────────────────────────────────────── */
.loader {
  grid-column: 1/-1;
  display: flex;
  justify-content: center;
  padding: 3rem;
}
.loader::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 .6rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}
.page-btn:hover:not(:disabled) { background: var(--surface-2); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Back button ─────────────────────────────────────────────────── */
.back-btn { margin-bottom: 1.5rem; }

/* ── Recipe detail ───────────────────────────────────────────────── */
.recipe-detail {}

.detail-hero {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.75rem;
  position: relative;
}
.detail-hero img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
}
.detail-hero-placeholder {
  height: 200px;
  background: linear-gradient(135deg, #f0ebe5, #e8dfd5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.75rem;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.detail-header h1 { font-size: 1.8rem; line-height: 1.25; }
.detail-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.75rem;
  font-size: .9rem;
}
.detail-meta-item { display: flex; align-items: center; gap: .4rem; }
.detail-meta-item strong { color: var(--text-muted); font-weight: 500; }

.detail-body {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}

.detail-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .9rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.ingredients-list li {
  padding: .35rem .6rem;
  background: var(--surface-2);
  border-radius: 5px;
  font-size: .9rem;
  border-left: 3px solid var(--primary);
}

.instructions-list {
  list-style: none;
  counter-reset: steps;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.instructions-list li {
  counter-increment: steps;
  display: flex;
  gap: .75rem;
  font-size: .92rem;
  line-height: 1.55;
}
.instructions-list li::before {
  content: counter(steps);
  min-width: 28px;
  height: 28px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* ── Form page ───────────────────────────────────────────────────── */
.page-title { font-size: 1.6rem; margin-bottom: 1.75rem; }

.recipe-form {}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.75rem;
}

.form-col { display: flex; flex-direction: column; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
}
.form-group label small { font-weight: 400; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.full-height { flex: 1; }
.full-height .textarea { flex: 1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .75rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: slide-in .25s ease;
  max-width: 340px;
}
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } }

/* ── Bouton admin ────────────────────────────────────────────────── */
.theme-btn { font-size: 1rem; padding: .35rem .6rem; }
.admin-btn { font-size: .85rem; padding: .35rem .85rem; }
.admin-btn.admin-active {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}
.admin-btn.admin-active:hover { background: #fde68a; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  animation: slide-up .2s ease;
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0; } }

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.login-error {
  color: #dc2626;
  font-size: .85rem;
  margin-bottom: .5rem;
  padding: .5rem .75rem;
  background: #fee2e2;
  border-radius: 6px;
}

/* ── Scaler portions ─────────────────────────────────────────────── */
.servings-scaler {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .85rem;
  background: var(--surface-2);
  padding: .4rem .85rem;
  border-radius: 7px;
  width: fit-content;
}
.scaler-label { font-size: .82rem; color: var(--text-muted); white-space: nowrap; }
.scaler-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}
.scaler-btn:hover:not(:disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.scaler-btn:disabled { opacity: .3; cursor: default; }
#scale-value { min-width: 28px; text-align: center; font-weight: 700; font-size: 1rem; }

.cart-add-btn {
  margin-top: 1rem;
  width: 100%;
  justify-content: center;
  font-size: .88rem;
  color: var(--primary);
  border-color: var(--primary);
}
.cart-add-btn:hover { background: #fdf5f2; }

/* ── Panier flottant (FAB) ───────────────────────────────────────── */
.cart-fab {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: transform .15s, background var(--transition), color var(--transition);
  cursor: pointer;
}
.cart-fab:hover { transform: scale(1.07); }
.cart-fab.cart-has-items {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 18px rgba(224,92,58,.38);
}
.cart-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  background: #dc2626;
  color: #fff;
  border-radius: 50%;
  font-size: .68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

/* ── Modal liste de courses ──────────────────────────────────────── */
.modal-box-lg {
  max-width: 520px;
  width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.modal-close-btn {
  padding: .3rem .6rem;
  font-size: .85rem;
  border-radius: 6px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
  flex-shrink: 0;
}
.shopping-toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.shopping-toolbar .btn { font-size: .82rem; padding: .35rem .75rem; }
.btn-active {
  background: #fdf5f2;
  color: var(--primary);
  border-color: var(--primary);
}

.shopping-items {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: .25rem;
}
.shopping-group { margin-bottom: 1.1rem; }
.shopping-group-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--primary);
  margin-bottom: .4rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .4rem;
  border-radius: 5px;
  font-size: .88rem;
  gap: .5rem;
}
.shopping-item:hover { background: var(--surface-2); }
.shopping-item-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.shopping-item-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shopping-check { accent-color: var(--primary); flex-shrink: 0; }
.shopping-check:checked + span { text-decoration: line-through; color: var(--text-muted); }

.shopping-item-source {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  flex-shrink: 0;
  font-style: italic;
}

/* ── Vue OCR ─────────────────────────────────────────────────────── */
.ocr-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

.ocr-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.ocr-panel { display: flex; flex-direction: column; gap: 1rem; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: #fdf5f2;
}
.drop-icon { font-size: 2.5rem; }
.drop-hint { font-size: .8rem; color: var(--text-muted); }

.file-previews {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}
.file-preview-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--surface-2);
  width: 120px;
}
.preview-img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}
.preview-pdf {
  width: 100%;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  padding: .5rem;
  text-align: center;
  word-break: break-all;
}
.preview-label {
  display: block;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem;
  background: var(--surface);
  color: var(--primary);
}
.preview-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.ocr-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .25rem;
}
.ocr-hint { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }

.ocr-raw {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem;
  border-radius: var(--radius);
  font-size: .78rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 400px;
  white-space: pre-wrap;
  word-break: break-word;
}

.ocr-result-header { margin-bottom: 1.25rem; }

/* ── Zone Editor ─────────────────────────────────────────────────── */
.zone-editor-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.zone-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .55rem;
  margin-left: .5rem;
  vertical-align: middle;
}

.zone-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.zone-toolbar-label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.zone-label-select { max-width: 200px; flex: 1; }

.zone-canvas-wrap {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
}

#zone-canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}

.zone-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.zone-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .4rem .75rem;
  background: var(--surface-2);
  border-radius: 7px;
  font-size: .85rem;
}

.zone-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zone-item-label {
  font-weight: 600;
  min-width: 90px;
}

.zone-item-coords {
  flex: 1;
  color: var(--text-muted);
  font-size: .78rem;
}

.zone-item-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .8rem;
  padding: .2rem .4rem;
  border-radius: 4px;
  line-height: 1;
}
.zone-item-del:hover { background: #fee2e2; color: #dc2626; }

/* ── Mode cuisine plein écran ────────────────────────────────────── */
.cooking-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.cooking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-shrink: 0;
}
.cooking-exit { font-size: .85rem; flex-shrink: 0; }
.cooking-recipe-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cooking-progress {
  font-size: .9rem;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
  min-width: 52px;
  text-align: right;
}
.cooking-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 2rem 1.5rem;
  overflow: auto;
}
.cooking-step-text {
  font-size: clamp(1.3rem, 4vw, 2rem);
  line-height: 1.65;
  text-align: center;
  max-width: 720px;
  font-weight: 500;
}
.cooking-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
  flex-shrink: 0;
}
.cooking-nav-btn {
  min-width: 130px;
  justify-content: center;
  font-size: .95rem;
  padding: .75rem 1.25rem;
}
.cooking-dots {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
}
.cooking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .2s, width .2s;
  flex-shrink: 0;
}
.cooking-dot.active { background: var(--primary); width: 22px; border-radius: 4px; }
.cooking-start-btn { margin-right: .25rem; }

/* ── Panneau ingrédients en mode cuisine ─────────────────────────── */
.cooking-ingredients-panel {
  width: 100%;
  max-width: 680px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  margin-bottom: 1.25rem;
}
.cooking-ingredients-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  background: var(--surface-2);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.cooking-ingredients-toggle:hover { background: var(--border); }
.cooking-toggle-arrow { margin-left: auto; font-size: .8rem; color: var(--text-muted); }
.cooking-ingredients-list {
  display: none;
  flex-direction: column;
  list-style: none;
  padding: .5rem 1rem .75rem;
  gap: .3rem;
  background: var(--surface);
  max-height: 40vh;
  overflow-y: auto;
}
.cooking-ingredients-list li {
  padding: .3rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.cooking-ingredients-list li:last-child { border-bottom: none; }
.cooking-ingredients-panel.open .cooking-ingredients-list { display: flex; }

/* ── Responsive ──────────────────────────────────────────────────── */

/* Tablette large (≤ 900px) */
@media (max-width: 900px) {
  :root { --max-width: 100%; }

  .detail-body { grid-template-columns: 1fr; }

  .recipes-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  }
}

/* Tablette / petite fenêtre (≤ 768px) */
@media (max-width: 768px) {
  /* Header : logo + nav en deux lignes si besoin */
  .header         { height: auto; min-height: var(--header-h); }
  .header-inner   { flex-wrap: wrap; padding: .5rem 1.25rem; gap: .4rem; }
  .logo           { flex: 1 0 auto; }
  .nav            { flex-wrap: wrap; gap: .25rem; }
  .nav-link       { font-size: .82rem; padding: .3rem .65rem; }

  /* Grille recettes */
  .recipes-grid   { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

  /* Filtres — important : flex:none pour que search-wrap ne prenne pas 280px de hauteur */
  .filters-bar    { flex-direction: column; gap: .6rem; }
  .search-wrap    { flex: none; width: 100%; }
  .filters        { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; }
  .filters .input { width: 100%; min-width: unset; }
  .clear-filters-btn { grid-column: 1 / -1; width: 100%; justify-content: center; }

  /* Détail */
  .detail-header h1 { font-size: 1.35rem; }
  .detail-hero img  { max-height: 260px; }

  /* Formulaire */
  .form-grid { grid-template-columns: 1fr; gap: 1.25rem; }

  /* OCR */
  .ocr-layout          { grid-template-columns: 1fr; }
  .zone-editor-wrap    { display: none; }

  /* Modal */
  .modal-box { padding: 1.75rem 1.25rem; }
}

/* Grand téléphone (≤ 600px) */
@media (max-width: 600px) {
  .recipes-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  .detail-header  { flex-direction: column; gap: .75rem; }
  .detail-actions { display: flex; gap: .5rem; }
  .detail-actions .btn { flex: 1; justify-content: center; }

  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; justify-content: center; }
}

/* Téléphone (≤ 480px) */
@media (max-width: 480px) {
  .cooking-nav-btn  { min-width: 90px; font-size: .82rem; padding: .6rem .9rem; }
  .cooking-step-text { font-size: clamp(1.1rem, 5vw, 1.5rem); }
  .cooking-header   { padding: .75rem 1rem; }
  .cooking-footer   { padding: 1rem; gap: .5rem; }
  :root { --header-h: auto; }

  .header-inner { padding: .5rem 1rem; }
  .container    { padding: 0 1rem; }

  /* Nav compacte */
  .nav-link     { font-size: .78rem; padding: .28rem .55rem; }
  .admin-text   { display: none; }        /* icône seule sur petit écran */
  .admin-btn    { padding: .3rem .55rem; }

  /* Recettes en 2 colonnes fixes */
  .recipes-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .card-title   { font-size: .95rem; }

  /* Form */
  .form-row     { grid-template-columns: 1fr; }
  .page-title   { font-size: 1.3rem; }

  /* Filtres en colonne */
  .filters      { grid-template-columns: 1fr; }

  /* Pagination */
  .page-btn { min-width: 34px; height: 34px; font-size: .82rem; }

  /* Modal */
  .modal-box { padding: 1.25rem 1rem; max-width: 100%; }
}

/* Très petit (≤ 360px) */
@media (max-width: 360px) {
  .recipes-grid { grid-template-columns: 1fr; }
  .logo span:last-child { display: none; }   /* cache le texte "Mes Recettes" */
}

/* ── Bouton menu sur les cartes ──────────────────────────────────── */
.menu-card-btn {
  position: absolute;
  top: 3rem;
  right: .6rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #e8e0d8;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0a090;
  box-shadow: 0 2px 6px rgba(0,0,0,.13);
  transition: transform .15s, color .15s, border-color .15s, box-shadow .15s;
  z-index: 2;
  line-height: 1;
}
[data-theme="dark"] .menu-card-btn { background: #2a2a3e; border-color: #444; color: #888; }
.menu-card-btn:hover { transform: scale(1.18); box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.menu-card-btn.menu-active { color: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(224,92,58,.3); }

/* ── Menu FAB ─────────────────────────────────────────────────────── */
.menu-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: transform .15s, background var(--transition), color var(--transition);
  cursor: pointer;
}
.menu-fab:hover { transform: scale(1.07); }
.menu-fab.menu-has-items {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 18px rgba(224,92,58,.38);
}
.menu-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

/* ── Modal menu ───────────────────────────────────────────────────── */
.menu-items { display: flex; flex-direction: column; gap: .5rem; padding: .5rem 0; min-height: 60px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .6rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: background var(--transition);
}
.menu-item:hover { background: var(--border); }
.menu-item-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.menu-item-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.menu-item-title {
  flex: 1;
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Boutons nav Menu & Favoris ──────────────────────────────────── */
.menu-nav-active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* ── Barre supérieure vue détail ─────────────────────────────────── */
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.print-btn { font-size: .85rem; }

/* ── Recettes similaires ─────────────────────────────────────────── */
.similar-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.similar-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; }
.similar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── Import URL ──────────────────────────────────────────────────── */
.url-import-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}
.url-import-wrap {
  display: flex;
  gap: .75rem;
  margin-top: .75rem;
}
.url-import-wrap .input { flex: 1; }

/* ── Impression ──────────────────────────────────────────────────── */
@media print {
  .header, .back-btn, .print-btn, .detail-actions, .cart-fab,
  .cart-add-btn, .servings-scaler, #pagination, .filters-bar,
  .similar-section, #toast-container, .cooking-overlay,
  .fav-btn, .menu-card-btn, nav { display: none !important; }

  body { background: #fff; color: #000; }
  .view { display: block !important; }
  #view-home, #view-form, #view-ocr { display: none !important; }
  #view-detail { display: block !important; }

  .detail-hero img { max-height: 280px; width: auto; margin: 0 auto 1rem; }
  .detail-body { display: block; }
  .detail-section { break-inside: avoid; margin-bottom: 1.5rem; }
  .ingredients-list li, .instructions-list li { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ── Bouton favori dans la vue détail ────────────────────────────── */
.fav-detail-btn.fav-active  { color: #f59e0b; border-color: #f59e0b; }
.menu-detail-btn.menu-active { color: var(--primary); border-color: var(--primary); }
