:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #1f1a17;
  --muted: #7a6f66;
  --line: #ebe4da;
  --accent: #c2410c;
  --accent-soft: #fdecdf;
  --danger: #b91c1c;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171412; --card: #221e1b; --text: #f3ede6; --muted: #a69a8f; --line: #35302b; --accent-soft: #3a2418; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

/* Kopbalk en tabbalk */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .actions { display: flex; gap: 4px; }
.logo { font-size: 1.4rem; }
main { padding: 14px 14px calc(90px + var(--safe-bottom)); max-width: 760px; margin: 0 auto; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom); z-index: 10;
}
.tabbar a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 0.75rem; color: var(--muted); text-decoration: none; }
.tabbar a span { display: block; font-size: 1.3rem; }
.tabbar a.active { color: var(--accent); }

/* Knoppen */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { padding: 7px 12px; font-size: 0.875rem; }
.btn.tiny { padding: 3px 8px; font-size: 0.75rem; }
.btn.block { width: 100%; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: 0.6; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%;
  border: none; background: transparent; color: var(--text); font-size: 1.3rem; text-decoration: none; cursor: pointer;
}
.icon-btn:active { background: var(--line); }

/* Formulieren */
input, textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.form .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.preview { height: 140px; border-radius: 10px; background: center/cover; }
.notice { background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; }

/* Overzicht */
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 0.85rem; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; border: 1px solid var(--line); }
.thumb { aspect-ratio: 4/3; background: var(--accent-soft) center/cover; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.card-body { padding: 10px; }
.card-body h3 { font-size: 0.95rem; line-height: 1.3; }
.card-body p { margin: 4px 0 0; }
.empty { grid-column: 1/-1; text-align: center; padding: 40px 0; color: var(--muted); }

/* Receptkaart */
.hero { margin: -14px -14px 0; aspect-ratio: 16/10; max-height: 340px; background: center/cover; }
.recipe h2 { font-size: 1.5rem; margin-top: 14px; }
.lead { margin: 6px 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 6px; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; }
.recipe section { margin-top: 20px; }
.recipe h3 { font-size: 1.1rem; margin-bottom: 8px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { border-bottom: 1px solid var(--line); }
.ingredients li.section { font-weight: 700; padding: 12px 0 6px; border: none; }
.ingredients label { display: flex; gap: 10px; align-items: center; padding: 9px 0; }
.ingredients input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.steps { padding-left: 0; list-style: none; counter-reset: step; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 16px 40px; line-height: 1.5; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.notes { white-space: pre-wrap; }
.links { display: flex; flex-direction: column; gap: 8px; }
.danger-zone { margin-top: 36px; text-align: center; }

/* Importeren */
.segmented { display: flex; background: var(--line); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.segmented button { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--text); }
.segmented button.active { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.divider { text-align: center; margin: 20px 0; color: var(--muted); position: relative; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.divider span { position: relative; background: var(--bg); padding: 0 10px; }

/* Groepen */
.groups { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.group { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.group h3 { font-size: 1rem; }
.group p { margin: 4px 0 0; }
code { background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; font-weight: 700; letter-spacing: 1px; }
.account { margin-top: 30px; text-align: center; }

/* Inloggen */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.logo-big { font-size: 3.5rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 100; max-width: 90vw; font-size: 0.9rem; animation: pop .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ───── v0.2: kookmodus, timers, boodschappen ───── */
.tabbar a { position: relative; }
.badge { position: absolute; top: 4px; left: 50%; margin-left: 8px; background: var(--accent); color: #fff; font-size: 0.65rem; min-width: 18px; padding: 1px 5px; border-radius: 999px; }
.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.cook { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 20; }
.cook-top { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; }
.cook-title { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 4px; background: var(--line); }
.progress div { height: 100%; background: var(--accent); transition: width .25s; }
.cook-main { flex: 1; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px; max-width: 760px; margin: 0 auto; width: 100%; }
.cook-step { text-align: center; width: 100%; }
.step-num { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 0.85rem; }
.step-text { font-size: clamp(1.35rem, 5vw, 2rem); line-height: 1.45; margin: 14px 0 22px; }
.big { font-size: 4rem; }
.timer-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.timer-btn { font-size: 1.05rem; background: var(--accent-soft); border-color: var(--accent); }
.cook-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.cook-nav .btn { min-width: 120px; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 30; }
.sheet-inner { background: var(--card); width: 100%; max-height: 75vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 14px 18px calc(18px + var(--safe-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }

#timerbar { position: fixed; top: calc(60px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 40; display: flex; flex-direction: column; gap: 6px; max-width: 70vw; }
.timer { display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg); padding: 6px 6px 6px 12px; border-radius: 999px; font-size: 0.85rem; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.timer .t-label { max-width: 34vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; opacity: .8; }
.timer strong { font-variant-numeric: tabular-nums; }
.timer button { border: none; background: transparent; color: inherit; font-size: 1rem; padding: 2px 6px; }
.timer.done { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.inline-form.top { margin: 0 0 8px; }
.aisle { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 0 4px; }
.shop-list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.shop-list li { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding-left: 12px; }
.shop-list li:last-child { border-bottom: none; }
.shop-list label { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.shop-list input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.shop-list small { display: block; color: var(--muted); font-size: 0.75rem; }
.shop-list li.checked span { text-decoration: line-through; color: var(--muted); }
.small-x { font-size: 0.9rem; color: var(--muted); }
.shop-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }

/* Zwevende knop: recept toevoegen */
.fab {
  position: fixed; right: 18px; bottom: calc(78px + var(--safe-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; text-decoration: none;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}
.fab:active { transform: scale(.95); }
