:root {
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f3ece1;
  --text: #2a2420;
  --muted: #74685d;
  --border: #e6dccd;
  --accent: #c8553d;
  --accent-ink: #ffffff;
  --accent-soft: #f8e1d9;
  --ok: #2f7d4f;
  --ok-soft: #dff0e5;
  --warn: #a8641c;
  --warn-soft: #f8ead6;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --surface: #25211d;
    --surface-2: #2f2a25;
    --text: #f1ebe3;
    --muted: #b0a497;
    --border: #3d362f;
    --accent: #e57a5f;
    --accent-ink: #1b1815;
    --accent-soft: #4a2c23;
    --ok: #7ccf9a;
    --ok-soft: #22392b;
    --warn: #e9b072;
    --warn-soft: #43341f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
}
h1, h2, h3, .card h3, .modal h2 { font-family: Fraunces, Georgia, serif; }
button, input, select { font: inherit; color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.hero { padding: 36px 0 20px; }
.hero h1 { margin: 0; font-size: clamp(30px, 6vw, 46px); letter-spacing: -.01em; }
.hero p { margin: 6px 0 0; color: var(--muted); font-size: 17px; }

.layout {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 16px;
}
@media (max-width: 860px) { .panel { position: static; } }
.panel h2 { margin: 0 0 12px; font-size: 21px; }
.panel h3 { margin: 20px 0 8px; font-size: 14px; font-family: Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.add-form { display: flex; gap: 8px; }
.add-form input {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.add-form input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.add-form button {
  padding: 10px 14px;
  border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer;
}
.hint { margin: 6px 0 12px; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 6px 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 14px; font-weight: 500;
}
.chip button {
  border: 0; background: transparent; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  line-height: 1; color: var(--muted);
}
.chip button:hover { background: var(--surface); color: var(--text); }
.empty-fridge { color: var(--muted); font-size: 14px; font-style: italic; }

.link-btn { margin-top: 8px; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button {
  border: 1px dashed var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}
.quick button:hover { border-color: var(--accent); color: var(--accent); }

.pantry { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 14px; }
.pantry label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.pantry input { accent-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer; font-weight: 500; font-size: 14px;
}
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters { display: flex; gap: 12px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.filters select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
}

.summary { color: var(--muted); margin: 14px 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.card {
  display: flex; flex-direction: column;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .emoji { font-size: 34px; line-height: 1; }
.card h3 { margin: 10px 0 2px; font-size: 19px; line-height: 1.25; }
.origin { font-size: 13px; color: var(--muted); }
.meta { display: flex; gap: 10px; font-size: 13px; color: var(--muted); margin-top: 8px; }

.badge {
  font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.bar { height: 5px; background: var(--surface-2); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.missing { margin-top: 8px; font-size: 13px; color: var(--muted); }
.missing b { color: var(--warn); font-weight: 600; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Modal */
.modal {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal::backdrop { background: rgba(20, 15, 10, .55); }
.modal article { padding: 24px; }
.modal-head { display: flex; gap: 14px; align-items: flex-start; }
.modal-head .emoji { font-size: 48px; line-height: 1; }
.modal h2 { margin: 0; font-size: 26px; line-height: 1.2; }
.close {
  margin-left: auto; flex: none;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: var(--surface-2);
  cursor: pointer; font-size: 18px;
}
.specialty {
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: 12px;
}
.specialty strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 16px; margin-bottom: 4px; }
.specialty p { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; }
@media (max-width: 600px) { .cols { grid-template-columns: 1fr; } }
.modal h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ing-list .st { width: 18px; flex: none; text-align: center; font-weight: 700; }
.ing-list .have .st { color: var(--ok); }
.ing-list .lack .st { color: var(--warn); }
.ing-list .q { color: var(--muted); margin-left: auto; text-align: right; }
.ing-list .opt { font-size: 11px; color: var(--muted); }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 10px; }
.copy-btn {
  margin-top: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer; font-size: 13px;
}

.footer { padding: 32px 16px; color: var(--muted); font-size: 13px; text-align: center; }

/* Recettes en ligne (Spoonacular) */
.online { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--border); }
.online-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.online h2 { margin: 0; font-size: 24px; }
.online .summary { margin: 4px 0 0; }
#online-msg:empty { display: none; }
#online-msg { margin: 14px 0; }
.primary {
  padding: 10px 16px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer;
}
.primary:disabled { opacity: .6; cursor: wait; }
#online-grid { margin-top: 14px; }
.card.photo { padding: 0; overflow: hidden; }
.card.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.card.photo .body { padding: 12px 14px 14px; }
.card.photo h3 { margin: 6px 0 0; font-size: 17px; }
.credit { font-size: 12px; color: var(--muted); margin-top: 14px; }
.credit a, .source a { color: inherit; }
.modal-photo { width: 100%; max-height: 300px; object-fit: cover; border-radius: 12px; margin-bottom: 16px; display: block; }
.source { margin-top: 18px; font-size: 13px; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
