:root, :root[data-theme="light"] {
  --bg: #f6f3ef;
  --card: #ffffff;
  --ink: #262326;
  --muted: #6e686a;
  --line: #e7e0da;
  --accent: #7a1f2e;
  --accent-soft: #f6e5e8;
  --ok: #2f6b4f;
  --ok-soft: #e3efe8;
  --tomato: #d4553a;
  --tomato-soft: #fbe6e0;
  --amber: #b07a0e;
  --amber-soft: #fbf0d6;
  --star: #e8a317;
  --ninja: #3b4a63;
  --tmx: #2d7a6e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 32, .06), 0 4px 14px rgba(40, 30, 32, .06);
  color-scheme: light;
}
/* Gris anthracite */
:root[data-theme="anthracite"] {
  --bg: #1d1f22; --card: #282b2f; --ink: #ecebea; --muted: #a4a6aa; --line: #3a3d42;
  --accent: #e3909b; --accent-soft: #48272d; --ok: #74c79b; --ok-soft: #23352b;
  --tomato: #f08068; --tomato-soft: #452821; --amber: #e8b553; --amber-soft: #3e3420;
  --shadow: none; color-scheme: dark;
}
/* Bordeaux très foncé */
:root[data-theme="bordeaux"] {
  --bg: #12060a; --card: #1d0b11; --ink: #f3e8e4; --muted: #b9989c; --line: #38151e;
  --accent: #d8b46e; --accent-soft: #3a2b16; --ok: #8fcfa6; --ok-soft: #16271d;
  --tomato: #ff8a7a; --tomato-soft: #44161b; --amber: #ff9a6a; --amber-soft: #4a1a14;
  --star: #e6c06d; --shadow: 0 1px 0 rgba(216, 180, 110, .06); color-scheme: dark;
}
:root[data-theme="bordeaux"] .top, :root[data-theme="bordeaux"] .tabs { background: #170810; }
:root[data-theme="bordeaux"] .card { border-color: #33131b; }
:root[data-theme="bordeaux"] .tipbox { background: #2a0f17; border-left: 3px solid var(--accent); }
:root[data-theme="anthracite"] .btn.primary, :root[data-theme="bordeaux"] .btn.primary { color: #1a090d; }
:root[data-theme="anthracite"] .steps li::before, :root[data-theme="bordeaux"] .steps li::before { color: #1a090d; }
.theme-btn { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; flex: none; }
.top-right { display: flex; gap: 6px; align-items: center; min-width: 0; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 84px;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin: 18px 0 10px; }
small, .muted { color: var(--muted); }

/* --- header --- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  justify-content: space-between; padding: 10px 16px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 26px; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { display: block; font-size: .75rem; margin-top: -2px; }
.profiles { display: flex; gap: 6px; overflow-x: auto; }
.pchip {
  border: 1.5px solid var(--line); background: transparent; border-radius: 999px;
  padding: 5px 12px 5px 8px; cursor: pointer; white-space: nowrap; display: flex; gap: 6px; align-items: center;
}
.pchip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* --- tabs (bottom on mobile) --- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid;
  grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  border: 0; background: none; padding: 8px 4px 10px; font-size: .75rem; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs button span { font-size: 1.25rem; }
.tabs button.on { color: var(--accent); font-weight: 600; }
@media (min-width: 820px) {
  body { padding-bottom: 30px; }
  .tabs { position: sticky; top: 57px; bottom: auto; display: flex; justify-content: center; gap: 4px; border-top: 0; border-bottom: 1px solid var(--line); }
  .tabs button { flex-direction: row; font-size: .95rem; padding: 10px 16px; gap: 6px; border-bottom: 2.5px solid transparent; }
  .tabs button span { font-size: 1rem; }
  .tabs button.on { border-bottom-color: var(--accent); }
}

main { max-width: 980px; margin: 0 auto; padding: 8px 16px 24px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

/* --- generic --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.btn {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px;
  cursor: pointer; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--tomato); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
.iconbtn { border: 0; background: none; cursor: pointer; font-size: 1.05rem; padding: 6px; border-radius: 8px; min-width: 34px; min-height: 34px; }
.iconbtn:hover { background: var(--accent-soft); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; min-height: 40px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 120px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
label.f > span { font-weight: 500; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: .88rem; color: var(--ink);
  display: inline-flex; gap: 4px; align-items: center;
}
.checks input { display: none; }
.checks label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--tomato-soft); color: var(--tomato); }
.chip.grey { background: var(--bg); color: var(--muted); }
.app { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: #fff; letter-spacing: .02em; }
.app.ninja { background: var(--ninja); }
.app.thermomix { background: var(--tmx); }
.app.other { background: var(--muted); }
.app.creami { background: #a8457a; }
.app.slushi { background: #2a6fb0; }
.app.juice { background: #c2701a; }
.app.kitchenaid { background: #5b6470; }
.app.woodfire { background: #8a4b22; }
.app.plancha { background: #6b5b95; }
.app.bbq { background: #3b3b3b; }
.app small { font-weight: 500; font-size: .95em; color: inherit; }
.thinking { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px; }
.dots { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- suggestions --- */
.urgent { border-left: 4px solid var(--tomato); }
.urgent .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0 10px; }
.toolbar input[type=search] { flex: 1 1 180px; width: auto; }
.toolbar select { width: auto; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; cursor: pointer; }
.rcard { cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s; }
.rcard:hover { border-color: var(--accent); }
.rcard h3 { font-size: 1.02rem; }
.rc-top { display: flex; justify-content: space-between; gap: 6px; align-items: flex-start; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: .84rem; color: var(--muted); align-items: center; }
.reasons { display: flex; flex-wrap: wrap; gap: 5px; }
.reasons .chip, .urgent .chip { white-space: normal; max-width: 100%; }
.status { font-size: .86rem; padding: 6px 10px; border-radius: 10px; }
.status.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.status.miss { background: var(--amber-soft); color: var(--ink); }
.star { border: 0; background: none; font-size: 1.35rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 2px 4px; }
.star.on { color: var(--star); }
.score { font-size: .72rem; color: var(--muted); }
.excluded { opacity: .55; }

/* --- inventory --- */
.inv-group h2 { display: flex; align-items: center; gap: 8px; }
.inv-list { display: flex; flex-direction: column; gap: 6px; }
.inv-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; }
.inv-item .name { font-weight: 600; }
.inv-item .sub { font-size: .8rem; color: var(--muted); }
.qty { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; }
.qty button { border: 0; background: none; width: 30px; height: 32px; cursor: pointer; font-size: 1.05rem; }
.qty span { min-width: 54px; text-align: center; font-size: .88rem; }
.quickdates { display: flex; gap: 4px; flex-wrap: wrap; }
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸ "; color: var(--muted); }
details.card[open] > summary::before { content: "▾ "; }
.shop-item { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.shop-item.done span { text-decoration: line-through; color: var(--muted); }

/* --- modal --- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 17, .5); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet {
  position: relative; background: var(--card); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 20px 18px 28px;
}
@media (min-width: 720px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
.close { position: sticky; top: 0; float: right; border: 0; background: var(--bg); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; z-index: 2; }
.detail h2 { font-size: 1.35rem; margin: 0 40px 6px 0; }
.detail .desc { color: var(--muted); margin: 0 0 10px; }
.ings { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.ings li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.ings .q { font-weight: 600; }
.ings .note { font-size: .8rem; color: var(--muted); }
.ings .sub { font-size: .8rem; color: var(--amber); }
.steps { padding-left: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; margin: 0; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 8px; }
.steps li::before { content: counter(s); background: var(--accent); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.tipbox { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin-top: 8px; font-size: .92rem; }
.tipbox b { display: block; margin-bottom: 2px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 0 4px; }
.stepper button { border: 0; background: none; width: 28px; height: 30px; cursor: pointer; font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: .92rem; max-width: 90vw; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.history li { padding: 4px 0; }
.help { font-size: .82rem; color: var(--muted); margin: 4px 0 0; }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
