:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #3a2414;
  --muted: #8a6d55;
  --line: #f0dfc4;
  --cheese: #f6b73c;
  --cheese-deep: #e8961e;
  --crust: #b5541c;
  --chip: #fff1d6;
  --chip-on: #3a2414;
  --chip-on-ink: #fff8ec;
  --ok: #3f8f4f;
  --shadow: 0 1px 0 rgba(58, 36, 20, .06), 0 8px 24px -12px rgba(58, 36, 20, .25);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c140e; --card: #2a1e15; --ink: #fbeedb; --muted: #c4a88c; --line: #3d2c1f;
    --chip: #382819; --chip-on: #f6b73c; --chip-on-ink: #241810; --crust: #f08a4b;
    --shadow: 0 8px 24px -12px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c140e; --card: #2a1e15; --ink: #fbeedb; --muted: #c4a88c; --line: #3d2c1f;
  --chip: #382819; --chip-on: #f6b73c; --chip-on-ink: #241810; --crust: #f08a4b;
  --shadow: 0 8px 24px -12px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* En-tête « fromage qui coule » */
.hero { position: relative; background: linear-gradient(160deg, #ffd166, var(--cheese) 55%, var(--cheese-deep)); color: #3a2414; }
.hero-inner { max-width: 640px; margin: 0 auto; padding: 28px 16px 22px; }
.kicker { margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; opacity: .75; }
h1 { margin: 4px 0 2px; font: 800 44px/1 Fraunces, Georgia, serif; letter-spacing: -.02em; }
.sub { margin: 6px 0 0; font-weight: 500; }
.drip {
  height: 22px; margin-bottom: -22px; position: relative; z-index: 1;
  background:
    radial-gradient(circle at 10% 0, var(--cheese-deep) 14px, transparent 15px),
    radial-gradient(circle at 34% 0, var(--cheese-deep) 9px, transparent 10px),
    radial-gradient(circle at 58% 0, var(--cheese-deep) 18px, transparent 19px),
    radial-gradient(circle at 83% 0, var(--cheese-deep) 11px, transparent 12px);
}

/* Onglets */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; overflow-x: auto;
  max-width: 640px; margin: 30px auto 0; padding: 8px 12px; background: var(--bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 1 0; min-width: max-content; border: 0; background: transparent; padding: 9px 8px; border-radius: 999px;
  font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--chip-on); color: var(--chip-on-ink); }

main { max-width: 640px; margin: 0 auto; padding: 8px 16px 120px; }
.timer { margin: 4px 2px 14px; color: var(--muted); font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.q { display: block; margin: 0 0 10px; font-weight: 700; font-size: 17px; }
.q small { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 4px; }
.q-small { font-size: 14px; margin-top: 14px; color: var(--muted); }

input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--bg); font-size: 17px; outline: none;
}
input:focus { border-color: var(--cheese); }

/* Boutons segmentés */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg-2 { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.seg-5 { grid-template-columns: repeat(5, 1fr); }
.seg button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 8px 6px; border-radius: 14px; border: 2px solid transparent;
  background: var(--chip); font-size: 20px; line-height: 1.1; transition: transform .08s, background .15s;
}
.seg-2 button, .seg-5 button { font-size: 14px; font-weight: 600; }
.seg button span { font-size: 13px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-ink); }
.seg button:active, .chips button:active { transform: scale(.96); }

/* Puces à choix multiples */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-diet { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.chips button {
  border: 2px solid transparent; background: var(--chip); padding: 9px 13px; border-radius: 999px;
  font-size: 15px; font-weight: 500; transition: transform .08s, background .15s;
}
.chips button[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-ink); }
.chips button[aria-pressed="true"]::before { content: "✓ "; }
.chips button[disabled] { opacity: .35; cursor: not-allowed; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%);
}
.cta {
  display: block; width: 100%; max-width: 608px; margin: 0 auto; border: 0; border-radius: 16px;
  padding: 16px; font-size: 18px; font-weight: 700; color: #3a2414;
  background: linear-gradient(180deg, #ffd166, var(--cheese)); box-shadow: 0 10px 24px -10px var(--cheese-deep);
}
.cta:disabled { opacity: .6; }
.error { color: var(--crust); font-weight: 600; margin: 4px 2px; }
.banner { background: var(--chip); border-radius: 14px; padding: 12px 14px; margin: 4px 0 12px; font-size: 14px; }

/* Listes de courses */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .qty { font-weight: 700; white-space: nowrap; }
.list .what { flex: 1; }
.list .what small { display: block; color: var(--muted); font-size: 13px; }
.buyer h3, .mine h2 { margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mine h2 { font: 800 28px/1.1 Fraunces, Georgia, serif; }
.buyer h3 { font-size: 18px; }
.price { font-size: 14px; color: var(--muted); font-weight: 600; }
.me { outline: 3px solid var(--cheese); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat b { display: block; font: 800 26px/1.1 Fraunces, Georgia, serif; }
.stat span { font-size: 12px; color: var(--muted); }
.ghost {
  border: 2px solid var(--line); background: transparent; border-radius: 12px; padding: 10px 14px; font-weight: 600;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tag { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 9px; font-size: 13px; margin: 2px 4px 2px 0; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 9;
  background: var(--chip-on); color: var(--chip-on-ink); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow);
}
@media (min-width: 560px) { h1 { font-size: 56px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.hint { margin: 10px 2px 0; font-size: 13px; color: var(--muted); }
.list .what small.pick { color: var(--ink); opacity: .8; }
