[hidden] { display: none !important; }
:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --ink: #2b2620;
  --muted: #7a6f63;
  --line: #e8dfd3;
  --accent: #c8553d;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3dc;
  --olive: #5f6f52;
  --olive-soft: #e7ecdf;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 38, 32, .06), 0 8px 24px rgba(43, 38, 32, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 80px; outline: none; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(250, 246, 240, .9);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: url(/icon.svg) center/cover; flex: none; }
.topnav { display: flex; gap: 6px; align-items: center; }
.topnav a, .topnav button {
  text-decoration: none; background: none; border: 0; cursor: pointer;
  padding: 8px 12px; border-radius: 999px; font-size: .92rem; color: var(--muted);
}
.topnav a:hover, .topnav button:hover { background: var(--line); color: var(--ink); }

/* ---- Buttons & inputs ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .95rem; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #d6c9b8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #b44a34; border-color: #b44a34; }
.btn-danger { color: #a3302a; }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=url], textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: .85rem; font-weight: 400; margin: 4px 0 0; }

/* ---- Home ---- */
.hero { padding: 36px 0 20px; }
.hero h1 { font-family: var(--serif); font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.1; margin: 0 0 18px; letter-spacing: -.01em; }
.search { position: relative; max-width: 560px; }
.search input { padding-left: 44px; font-size: 1.05rem; border-radius: 999px; box-shadow: var(--shadow); border-color: transparent; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; font-size: .88rem; cursor: pointer;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.count { color: var(--muted); font-size: .9rem; margin: 8px 0 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; }
.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); text-decoration: none; display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(43,38,32,.06), 0 16px 32px rgba(43,38,32,.1); }
.card-img { aspect-ratio: 4 / 3; background: var(--accent-soft); position: relative; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-family: var(--serif); font-size: 3.4rem; color: rgba(255,255,255,.92);
}
.card-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-family: var(--serif); font-size: 1.2rem; line-height: 1.25; margin: 0; font-weight: 600; }
.card-desc { color: var(--muted); font-size: .9rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .85rem; margin-top: auto; padding-top: 6px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---- Recipe ---- */
.recipe { max-width: 920px; margin: 0 auto; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: .92rem; margin: 14px 0; }
.recipe-hero { border-radius: 22px; overflow: hidden; aspect-ratio: 16 / 8; background: var(--accent-soft); box-shadow: var(--shadow); }
.recipe-hero img { width: 100%; height: 100%; object-fit: cover; }
.recipe-head { margin: 26px 0 8px; }
.recipe-head h1 { font-family: var(--serif); font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.12; margin: 0 0 10px; letter-spacing: -.01em; }
.recipe-head .lead { color: var(--muted); font-size: 1.08rem; margin: 0 0 14px; max-width: 65ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--olive-soft); color: var(--olive); border-radius: 999px; padding: 3px 12px; font-size: .82rem; text-decoration: none; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px; min-width: 110px; }
.stat small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat strong { font-size: 1.05rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }

.recipe-cols { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 34px; margin-top: 22px; align-items: start; }
@media (max-width: 760px) { .recipe-cols { grid-template-columns: 1fr; gap: 22px; } .recipe-hero { aspect-ratio: 4 / 3; border-radius: 18px; } }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px 20px 10px; box-shadow: var(--shadow); }
.ingredients-panel { position: sticky; top: 76px; }
@media (max-width: 760px) { .ingredients-panel { position: static; } }
.panel h2, .section-title { font-family: var(--serif); font-size: 1.4rem; margin: 0 0 12px; }
.servings { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.servings button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; font-size: 1.2rem; line-height: 1; }
.servings span { font-weight: 600; font-size: .95rem; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.ing-list li:first-child { border-top: 0; }
.check { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 2px solid #d6c9b8; margin-top: 2px; display: grid; place-items: center; }
.ing-list li.done .check, .steps li.done .num { background: var(--olive); border-color: var(--olive); color: #fff; }
.ing-list li.done .check::after { content: "✓"; color: #fff; font-size: .75rem; font-weight: 700; }
.ing-list li.done .ing-text { color: var(--muted); text-decoration: line-through; }
.amount { font-weight: 700; white-space: nowrap; }
.ing-note { color: var(--muted); font-size: .88rem; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.steps li:first-child { border-top: 0; padding-top: 0; }
.num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
}
.steps li.done p { color: var(--muted); }
.steps p { margin: 4px 0 0; font-size: 1.04rem; }
.notes { margin-top: 26px; background: var(--olive-soft); border-radius: var(--radius); padding: 16px 20px; color: #3e4a35; }
.notes h3 { margin: 0 0 6px; font-size: 1rem; }
.notes p { margin: 0; white-space: pre-line; }
.source { margin-top: 20px; color: var(--muted); font-size: .92rem; }
.source a { color: var(--accent); }

/* ---- Forms / admin ---- */
.page-title { font-family: var(--serif); font-size: 2rem; margin: 28px 0 18px; }
.form { display: grid; gap: 18px; max-width: 820px; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.image-field { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.image-preview { width: 160px; aspect-ratio: 4 / 3; border-radius: 12px; background: var(--accent-soft); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.login { max-width: 380px; margin: 60px auto; background: var(--surface); padding: 28px; border-radius: 20px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.login h1 { font-family: var(--serif); margin: 0; }
.error { color: #a3302a; font-size: .9rem; margin: 0; min-height: 1.2em; }

.admin-list { display: grid; gap: 10px; }
.admin-item { display: flex; align-items: center; gap: 14px; background: var(--surface); padding: 10px; border-radius: 14px; box-shadow: var(--shadow); }
.admin-thumb { width: 64px; height: 48px; border-radius: 9px; overflow: hidden; flex: none; background: var(--accent-soft); }
.admin-thumb img, .admin-thumb .placeholder { width: 100%; height: 100%; object-fit: cover; font-size: 1.4rem; }
.admin-item .grow { flex: 1; min-width: 0; }
.admin-item .grow a { font-weight: 600; text-decoration: none; }
.admin-item .grow small { display: block; color: var(--muted); }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
pre.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: .85rem; overflow: auto; max-height: 260px; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  .topbar, .toolbar, .back, .servings button, #toast { display: none !important; }
  .panel { box-shadow: none; }
  .ingredients-panel { position: static; }
}

/* ---- Bewerken in receptweergave ---- */
.editor input, .editor textarea { background: transparent; border: 1px dashed transparent; border-radius: 10px; box-shadow: none; }
.editor input:hover, .editor textarea:hover { border-color: #d6c9b8; }
.editor input:focus, .editor textarea:focus { background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor textarea { min-height: 0; resize: none; overflow: hidden; }
.editor-banner { background: var(--accent-soft); color: #8a3a28; border-radius: 12px; padding: 10px 14px; font-size: .92rem; margin-bottom: 14px; }
.edit-hero { position: relative; }
.edit-hero #heroimg, .edit-hero img { width: 100%; height: 100%; object-fit: cover; }
.no-photo { width: 100%; height: 100%; display: grid; place-items: center; color: #a86b5c; font-size: 1rem; border: 2px dashed #e4bcae; border-radius: 22px; }
.hero-actions { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
.edit-title { font-family: var(--serif); font-size: clamp(1.9rem, 5vw, 2.8rem); font-weight: 700; line-height: 1.15; padding: 4px 8px; margin-left: -9px; letter-spacing: -.01em; }
.edit-lead { color: var(--muted); font-size: 1.08rem; padding: 6px 8px; margin-left: -9px; }
.edit-tags { color: var(--olive); font-size: .9rem; padding: 6px 8px; margin-left: -9px; }
.editor .stat { margin: 0; font-weight: 400; cursor: text; }
.editor .stat input { width: 90px; padding: 2px 4px; margin-left: -5px; font-weight: 700; font-size: 1.05rem; border-radius: 6px; }

.ing-head, .ing-row { display: grid; grid-template-columns: 58px 70px 1fr auto; gap: 6px; align-items: start; }
.ing-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 0 4px; }
.ing-row { padding: 6px 0; border-top: 1px solid var(--line); }
.ing-row input { padding: 6px 6px; font-size: .95rem; }
.ing-row .i-amount { font-weight: 700; text-align: right; }
.ing-row .i-unit { font-weight: 700; }
.ing-row .i-note { font-size: .85rem; color: var(--muted); padding-top: 2px; }
.i-main { display: grid; }
.row-tools { display: flex; gap: 2px; opacity: .35; transition: opacity .15s; }
.ing-row:hover .row-tools, .ing-row:focus-within .row-tools,
.edit-steps li:hover .row-tools, .edit-steps li:focus-within .row-tools { opacity: 1; }
@media (hover: none) { .row-tools { opacity: .8; } }
.row-tools button { width: 26px; height: 26px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: .95rem; }
.row-tools button:hover { background: var(--line); color: var(--ink); }
.row-tools button[data-act=del]:hover { background: #fbe4e1; color: #a3302a; }
.add-btn { margin: 10px 0 6px; }
.editor .ingredients-panel { position: static; }


.edit-steps li { cursor: default; align-items: flex-start; gap: 10px; }
.edit-steps textarea { flex: 1; font-size: 1.04rem; padding: 4px 8px; }
.edit-steps .num { margin-top: 2px; }
.editor .notes textarea { color: #3e4a35; padding: 4px 6px; margin-left: -7px; width: calc(100% + 7px); }
.source-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.source-edit label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.source-edit input { margin-top: 2px; border: 1px solid var(--line); background: var(--surface); padding: 8px 10px; font-size: .92rem; }
@media (max-width: 640px) { .source-edit { grid-template-columns: 1fr; } }
.edit-hero.empty { aspect-ratio: auto; height: 130px; box-shadow: none; background: transparent; }
.ing-row input.i-amount:not(:focus)::placeholder, .ing-row input.i-unit:not(:focus)::placeholder,
.ing-row input.i-note:not(:focus)::placeholder { color: transparent; }
.ing-row:hover input.i-note::placeholder { color: #b9ad9f; }
@media (max-width: 760px) {
  .ing-head { display: none; }
  .ing-row { grid-template-columns: 56px 1fr auto; grid-template-areas: "amt unit tools" "main main main"; row-gap: 0; }
  .ing-row .i-amount { grid-area: amt; text-align: left; }
  .ing-row .i-unit { grid-area: unit; }
  .ing-row .i-main { grid-area: main; }
  .ing-row .row-tools { grid-area: tools; }
  .ing-row .i-amount:not(:focus)::placeholder, .ing-row .i-unit:not(:focus)::placeholder { color: #c9bdaf; }
}
@media (max-width: 760px) {
  .ing-row .i-note:placeholder-shown:not(:focus) { height: 0; padding: 0; border: 0; }
  .ing-row:focus-within .i-note { height: auto; padding: 2px 6px; border: 1px dashed transparent; }
  .editor .stats { display: grid; grid-template-columns: repeat(3, 1fr); }
  .editor .stat { min-width: 0; padding: 8px 10px; }
  .editor .stat small { font-size: .68rem; }
  .editor .stat input { width: 100%; }
}
.edit-hero #heroimg { position: absolute; inset: 0; }

/* Bewerkscherm: breed, ingrediënten over de volle breedte */
.recipe.editor { max-width: 1100px; }
.editor .recipe-cols { grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 761px) {
  .ing-head, .ing-row { grid-template-columns: 80px 120px minmax(180px, 1fr) minmax(200px, 1.3fr) auto; gap: 10px; align-items: center; }
  .i-main { display: contents; }
  .ing-row .i-note { font-size: .92rem; padding-top: 6px; }
  .ing-row input.i-note:not(:focus)::placeholder { color: transparent; }
  .ing-row:hover input.i-note::placeholder { color: #b9ad9f; }
  .ing-head span:last-child { width: 82px; }
}
