:root {
  --bg: #faf7f2; --card: #fff; --text: #1f1b16; --muted: #7a7068; --line: #e9e2d8;
  --accent: #e4572e; --accent-ink: #fff; --soft: #fdece6; --shadow: 0 2px 12px rgba(0,0,0,.08);
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161412; --card: #221f1c; --text: #f3ede6; --muted: #a39a90; --line: #35302b; --soft: #3a2620; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Pages */
.page { max-width: 680px; margin: 0 auto; padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 96px); }
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.topbar h1 { flex: 1; margin: 0; font-size: 1.5rem; line-height: 1.2; }
.topbar .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: #c0392b; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 1.1rem; }
.btn:disabled { opacity: .5; }
.icon-btn { border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; box-shadow: var(--shadow); flex: none; }

/* Accueil */
.search { width: 100%; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); outline: none; }
.search:focus { border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { display: block; text-decoration: none; color: inherit; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card .thumb { aspect-ratio: 4/3; background: var(--soft); display: grid; place-items: center; font-size: 2.2rem; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .body { padding: 10px 12px 12px; }
.card .name { font-weight: 600; line-height: 1.25; }
.card .meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* Recette */
.hero { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 12px; }
h2.recipe-title { margin: 4px 0 4px; font-size: 1.6rem; line-height: 1.2; }
.meta-line { color: var(--muted); font-size: .95rem; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { background: var(--soft); border-radius: 999px; padding: 2px 10px; font-size: .8rem; }
.stepper { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); margin: 12px 0; }
.stepper .val { font-weight: 700; font-size: 1.1rem; }
.stepper .icon-btn { box-shadow: none; background: var(--soft); font-weight: 700; }
.ing-group { margin: 14px 0 4px; font-weight: 700; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.ing-row { display: grid; grid-template-columns: 5rem auto 1fr; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ing-row input { width: 100%; text-align: right; border: 1px solid transparent; background: var(--soft); border-radius: 10px; padding: 6px 8px; font-weight: 700; outline: none; }
.ing-row input:focus { border-color: var(--accent); background: var(--card); }
.ing-row .unit { color: var(--muted); min-width: 1.2rem; }
.ing-row .nm { grid-column: 3; }
.ing-row.noqty .nm { grid-column: 1 / -1; }
.ing-row small { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(var(--safe-b) + 12px); background: linear-gradient(transparent, var(--bg) 35%); }
.sticky-cta .btn { max-width: 680px; margin: 0 auto; display: block; }

/* Feuilles (sheets) */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 88dvh; overflow-y: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 16px 16px calc(var(--safe-b) + 20px); max-width: 680px; margin: 0 auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; }
.sheet textarea { width: 100%; min-height: 220px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 10px; font: 13px/1.4 ui-monospace, Menlo, monospace; outline: none; resize: vertical; }
.sheet textarea:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row .btn { flex: 1; }
.msg { white-space: pre-wrap; font-size: .9rem; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--soft); }
.msg.err { color: #c0392b; }
.menu { display: grid; gap: 8px; }
.menu .btn { text-align: left; border-radius: 14px; }

/* Connexion */
.login { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 12px; text-align: center; }
.login .logo { font-size: 3rem; }
.login input { padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); outline: none; text-align: center; }

/* Mode cuisine */
.cook { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.cook-top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 14px 8px; }
.cook-top .count { flex: 1; text-align: center; font-weight: 700; }
.progress { height: 4px; background: var(--line); margin: 0 14px; border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.timers { display: flex; gap: 8px; padding: 0 14px; overflow-x: auto; }
.timers:empty { display: none; }
.timers .t { margin-top: 8px; flex: none; display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 6px 6px 6px 12px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; font-weight: 600; }
.timers .t.done { background: var(--accent); color: var(--accent-ink); animation: pulse 1s infinite; }
.timers .t button { border: 0; background: rgba(0,0,0,.08); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }
@keyframes pulse { 50% { opacity: .65; } }
.steps { flex: 1; min-height: 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; }
.step { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; flex-direction: column; padding: 16px 22px calc(var(--safe-b) + 88px); overflow-y: auto; }
.step-inner { margin: auto 0; max-width: 640px; width: 100%; align-self: center; }
.step .num { color: var(--accent); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: .9rem; }
.step .txt { font-size: 1.45rem; line-height: 1.4; margin: 8px 0 18px; }
.step-ings { display: grid; gap: 8px; margin-bottom: 14px; }
.step-ing { background: var(--card); border-left: 4px solid var(--accent); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); font-weight: 600; }
.step-ing small { color: var(--muted); font-weight: 400; }
.step .btn.timer { margin: 0 8px 8px 0; }
.step.end { text-align: center; }
.step.end .big-emoji { font-size: 4rem; }
.fab { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 18px); box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 5; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 90px); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 999px; z-index: 200; font-size: .9rem; }
