:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --ink: #33302b;
  --muted: #857f74;
  --accent: #c0392b;
  --accent-dark: #96281b;
  --gold: #e0a458;
  --line: #e8e0d2;
  --shadow: 0 2px 10px rgba(60, 45, 20, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  white-space: nowrap;
}
#search {
  flex: 1;
  max-width: 480px;
  padding: 9px 14px;
  border: none;
  border-radius: 20px;
  font-size: .95rem;
  font-family: inherit;
}

.btn {
  padding: 9px 16px;
  border: none;
  border-radius: 20px;
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary { background: var(--gold); color: #3d2b10; font-weight: bold; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: rgba(255,255,255,.18); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.3); }
.btn.danger { background: #f2dede; color: #96281b; }
.btn.danger:hover { background: #eccaca; }

/* ---------- Mise en page ---------- */
.layout {
  display: flex;
  min-height: calc(100vh - 62px);
}
.sidebar {
  width: 250px;
  flex-shrink: 0;
  padding: 18px 0 30px;
  border-right: 1px solid var(--line);
}
.sidebar button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 20px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: .95rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.sidebar button:hover { background: #f1e9db; }
.sidebar button.active {
  background: #f1e2d0;
  border-right: 3px solid var(--accent);
  font-weight: bold;
}
.sidebar .count {
  font-size: .78rem;
  color: var(--muted);
  background: var(--line);
  border-radius: 10px;
  padding: 1px 8px;
}
.sidebar hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 10px 20px;
}

.content { flex: 1; padding: 24px; }

/* ---------- Cartes ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(60, 45, 20, .14);
}
.card h3 { margin: 0; font-size: 1.05rem; color: var(--accent-dark); }
.card .cat { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card .meta { font-size: .85rem; color: var(--muted); }
.card .accomp {
  font-size: .85rem;
  color: var(--ink);
  font-style: italic;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.badge {
  align-self: flex-start;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e7f0e2;
  color: #3c6e2f;
}
.badge.livret { background: #f5e9d5; color: #8a6118; }

.empty { color: var(--muted); font-style: italic; padding: 30px; text-align: center; }

/* ---------- Overlays / panneaux ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 15, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px;
  z-index: 20;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.panel {
  position: relative;
  background: var(--card);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  margin-bottom: 4vh;
}
.panel .close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: none;
  font-size: 1.9rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.panel .close:hover { color: var(--accent); }

/* ---------- Fiche recette ---------- */
.detail h2 {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 1.6rem;
  padding-right: 30px;
}
.detail .cat { color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .05em; }
.detail .meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 14px 0;
  font-size: .95rem;
}
.detail .meta-line span strong { color: var(--accent-dark); }
.detail h4 {
  margin: 20px 0 8px;
  font-size: 1rem;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.detail ul { margin: 0; padding-left: 22px; }
.detail li { margin: 3px 0; }
.detail li.group { list-style: none; margin-left: -22px; font-weight: bold; color: var(--accent-dark); margin-top: 8px; }
.detail p { margin: 0 0 10px; line-height: 1.55; }
.detail .conseils {
  background: #fdf6e8;
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}
.detail .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.detail .actions .btn.ghost { background: var(--line); color: var(--ink); }

/* ---------- Formulaire ---------- */
.form-panel h2 { margin-top: 0; color: var(--accent-dark); }
#recipe-form label {
  display: block;
  margin-bottom: 14px;
  font-size: .92rem;
  color: var(--accent-dark);
  font-weight: bold;
}
#recipe-form small { font-weight: normal; color: var(--muted); }
#recipe-form input[type=text],
#recipe-form select,
#recipe-form textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: normal;
  color: var(--ink);
  background: #fffdf9;
}
#recipe-form textarea { resize: vertical; }
#recipe-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
#recipe-form .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
#recipe-form .actions .btn.ghost { background: var(--line); color: var(--ink); }
.form-error { color: var(--accent); font-weight: bold; }

/* ---------- Thermostat ---------- */
.thermo { border-collapse: collapse; width: 100%; margin: 12px 0; }
.thermo td { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.thermo .pos {
  font-weight: bold;
  color: var(--accent);
  width: 70px;
  text-align: center;
  font-size: 1.1rem;
}
.note { color: var(--muted); font-size: .92rem; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  #search { order: 3; max-width: none; width: 100%; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px;
  }
  .sidebar button { width: auto; white-space: nowrap; border-radius: 16px; }
  .sidebar button.active { border-right: none; background: #f1e2d0; }
  .sidebar hr { display: none; }
  #recipe-form .row { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
}
