:root {
  --bg: #f7f2ea;
  --card: #fffdf9;
  --ink: #2a2723;
  --muted: #7a7166;
  --line: #e7dfd3;
  --accent: #c4553a;
  --accent-ink: #fff;
  --sage: #5d7f5b;
  --sage-soft: #e5eee1;
  --gold: #d79b2b;
  --gold-soft: #fbefd6;
  --danger: #b23a3a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17; --card: #26231f; --ink: #f1ebe2; --muted: #a99f92; --line: #3a352f;
    --accent: #e0714f; --sage: #8fb38c; --sage-soft: #2c3a2b; --gold: #e5b04a; --gold-soft: #3b3020;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans);
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin: 22px 0 10px; }
h3 { font-size: 1.05rem; }
button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.3rem; text-align: center; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; cursor: pointer;
}
.icon-btn:active { background: var(--line); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; padding: 8px 0 10px; font-size: .72rem; color: var(--muted);
}
.tabbar a span { display: block; font-size: 1.35rem; line-height: 1.3; }
.tabbar a.on { color: var(--accent); font-weight: 600; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
}
.banner { border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: .92rem; }
.banner.info { background: var(--gold-soft); }
.banner.ok { background: var(--sage-soft); }
.banner.err { background: #f8dcd6; color: #7a1f12; }
@media (prefers-color-scheme: dark) { .banner.err { background: #4a2320; color: #ffd5cc; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px;
  padding: 10px 16px; background: var(--line); cursor: pointer; text-decoration: none; font-weight: 500; min-height: 42px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.sage { background: var(--sage); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .88rem; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-size: .78rem;
  background: var(--line); white-space: nowrap;
}
.chip.sage { background: var(--sage-soft); color: var(--sage); }
.chip.gold { background: var(--gold-soft); color: #8a5a00; }
@media (prefers-color-scheme: dark) { .chip.gold { color: var(--gold); } }
.chip.accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

/* Semaine */
.weeksum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.weeksum div { background: var(--card); border-radius: 12px; padding: 8px 10px; box-shadow: var(--shadow); text-align: center; }
.weeksum b { display: block; font-size: 1.15rem; font-family: var(--serif); }
.weeksum small { color: var(--muted); font-size: .74rem; }
.day { position: relative; }
.day.off { opacity: .55; }
.day.today { outline: 2px solid var(--accent); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.day-head b { text-transform: capitalize; font-family: var(--serif); font-size: 1.05rem; }
.wx { font-size: .85rem; color: var(--muted); }
.day .title { display: block; text-decoration: none; font-weight: 650; font-size: 1.08rem; margin: 2px 0 4px; }
.day .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.day .actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 10px; }
.day .actions .btn { flex: 1; min-width: 0; padding: 6px 8px; font-size: .82rem; min-height: 34px; }
.btn.on { background: var(--sage-soft); color: var(--sage); }
.stars { color: var(--gold); letter-spacing: 1px; }

/* Recette */
.hero h1 { font-size: 1.55rem; margin-bottom: 6px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.facts div { background: var(--card); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); font-size: .9rem; }
.facts b { display: block; font-size: .74rem; color: var(--muted); font-weight: 500; }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ing li:last-child { border: 0; }
.ing .q { color: var(--muted); white-space: nowrap; text-align: right; }
.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 4px 0 12px 40px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.rate button { border: 0; background: none; font-size: 1.7rem; color: var(--line); cursor: pointer; padding: 0 2px; }
.rate button.on { color: var(--gold); }
textarea, input[type=text], input[type=password], select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card);
}
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; margin: 10px 0 4px; font-weight: 500; font-size: .9rem; }

/* Mode cuisine */
.cook { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom)); }
.cook .progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 20px; }
.cook .progress div { height: 100%; background: var(--accent); transition: width .3s; }
.cook .step { flex: 1; overflow: auto; font-size: 1.6rem; line-height: 1.4; font-family: var(--serif); }
.cook .nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cook .nav .btn { min-height: 56px; font-size: 1.1rem; }

.timers { position: fixed; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 6px; }
.timer { background: var(--ink); color: var(--bg); border-radius: 999px; padding: 8px 14px; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; }
.timer.done { background: var(--accent); color: #fff; animation: pulse 1s infinite; }
.timer button { background: none; border: 0; color: inherit; font-size: 1rem; cursor: pointer; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* Courses */
.seg { display: flex; background: var(--line); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 8px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }
.store-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.store-h h3 { flex: 1; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border: 0; }
.item input { width: 22px; height: 22px; accent-color: var(--sage); flex: none; }
.item .n { flex: 1; min-width: 0; }
.item .n small { display: block; color: var(--muted); font-size: .76rem; }
.item.done .n { text-decoration: line-through; color: var(--muted); }
.item .q { white-space: nowrap; color: var(--muted); font-size: .9rem; }
details summary { cursor: pointer; font-weight: 500; padding: 4px 0; }

/* Divers */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill .x { margin-left: 6px; opacity: .6; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-grid a { text-decoration: none; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.menu-grid a span { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.menu-grid a small { color: var(--muted); display: block; font-size: .8rem; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 70; display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto; }
.loading { text-align: center; padding: 40px 10px; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top)); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 90; font-size: .92rem; max-width: 90vw; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .big { font-size: 3rem; }
