:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e7e2d9;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 41, 55, .06), 0 8px 24px rgba(31, 41, 55, .06);
  --fs-base: 18px;
  --fs-scale: 1; /* gezet door de A-/A+ knoppen */
  --fs-body: calc(var(--fs-base) * var(--fs-scale));
  --lh: 1.65;
  --measure: 62ch;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-body)/var(--lh) system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* .btn zet display, dat wint anders van het hidden-attribuut */
[hidden] { display: none !important; }

a { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(250, 247, 242, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink);
}

.topbar-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { border-color: #d6cfc2; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost.active { background: var(--accent-soft); border-color: #f3d18a; }
.btn-danger { background: #fff; border-color: #f3c1c1; color: #b91c1c; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- Overzicht ---------- */
.list-head { margin-bottom: 20px; }

.search {
  width: 100%;
  padding: 14px 18px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.tagbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.tag-chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

.tag-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease;
}

.card:hover { transform: translateY(-2px); }

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(140deg, #f6efe1, #efe6d4);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-ph { font-size: 2.6rem; opacity: .5; }

.card-count {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: .75rem;
}

.card-body { padding: 16px 18px 18px; }
.card-title { margin: 0 0 6px; font-size: 1.1rem; }

.card-desc {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta, .card-tags, .facts { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tags { margin-top: 10px; }

.meta-pill, .tag {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .82rem;
  background: #f3efe7;
  color: var(--muted);
}

.tag { background: var(--accent-soft); color: #92400e; }

.empty, .muted { color: var(--muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------- Receptpagina ---------- */
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: .92rem; }
.recipe-head h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; }
.lead { margin: 0 0 14px; color: var(--muted); max-width: var(--measure); }
.facts { margin-bottom: 16px; }

.toolbar {
  position: sticky;
  top: 61px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  background: linear-gradient(var(--bg) 80%, rgba(250, 247, 242, 0));
}

.scale { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.scale-label { color: var(--muted); font-size: .9rem; margin-right: 4px; }
.textsize { display: flex; gap: 4px; }

.ts-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: inherit;
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
}

.ts-btn:hover:not([disabled]) { border-color: #d6cfc2; }
.ts-btn[disabled] { opacity: .35; cursor: default; }

.scale-btn {
  min-width: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  cursor: pointer;
}

.scale-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.hero {
  display: block;
  width: 100%;
  padding: 0;
  margin-bottom: 8px;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: none;
  cursor: zoom-in;
}

.hero img { width: 100%; max-height: 380px; object-fit: cover; display: block; }

.recipe-grid {
  display: grid;
  /* em: de ingredientenkolom groeit mee als je de tekst vergroot */
  grid-template-columns: minmax(240px, 24em) 1fr;
  gap: 32px;
  align-items: start;
}

.ingredients {
  position: sticky;
  top: 130px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 22px;
}

/* em zodat de receptinhoud meeschaalt met de A-/A+ knoppen */
.ingredients h2, .steps h2 { font-size: 1.15em; margin: 0 0 12px; }

.ing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 12px;
}

.ing-head h2 { margin: 0; }
.ing-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ing-mini { padding: 5px 12px; font-size: .8em; color: var(--muted); white-space: nowrap; }
.ing-mini:hover { color: var(--ink); }

/* Ingeklapt: de stappen krijgen de volle breedte, handig op een tablet tijdens het koken.
   body:not(.ing-sheet) houdt deze regels weg zodra het paneel openstaat. */
.recipe-grid.ing-hidden { grid-template-columns: 1fr; }
body:not(.ing-sheet) .recipe-grid.ing-hidden .ingredients { position: static; padding: 10px 20px; }
body:not(.ing-sheet) .recipe-grid.ing-hidden .ing-head { margin-bottom: 0; }
body:not(.ing-sheet) .recipe-grid.ing-hidden #ing-body { display: none; }

/* Zwevende knop: blijft binnen duimbereik terwijl je door de stappen scrolt */
.ing-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  box-shadow: 0 8px 24px rgb(0 0 0 / .22);
  cursor: pointer;
}

.ing-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .4); }

/* Ingrediënten als paneel over de stappen heen, zodat je je plek niet kwijtraakt */
body.ing-sheet .ingredients {
  position: fixed;
  z-index: 55;
  inset: auto 0 0;
  margin: 0 auto;
  width: min(560px, 100%);
  max-height: 72vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px 20px calc(78px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgb(0 0 0 / .3);
}

body.ing-sheet #ing-body { display: block; }

body.ing-sheet .ing-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 8px;
  padding: 14px 0 10px;
  background: var(--card);
}

body.ing-sheet #ing-toggle { display: none; }

.group-title { margin: 18px 0 6px; font-size: .95em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ing-list { list-style: none; margin: 0; padding: 0; }

.ing {
  display: grid;
  grid-template-columns: 20px minmax(3.4em, auto) 1fr;
  align-items: start;
  gap: 4px 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}

.ing:last-child { border-bottom: 0; }

.ing-amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.ing-amount:empty { display: none; }
.ing-amount:empty + .ing-name { grid-column: 2 / -1; }

.check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 5px;
  border: 2px solid #d6cfc2;
  border-radius: 5px;
}

.ing.done { color: var(--muted); }
.ing.done .ing-amount, .ing.done .ing-name { text-decoration: line-through; }
.ing.done .check { background: var(--accent); border-color: var(--accent); }
.qty { font-weight: inherit; }

.step-list { list-style: none; margin: 0; padding: 0; }

.step {
  padding: 16px 20px 18px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step.done { opacity: .5; }

.step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

.step-num {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #92400e;
  font-weight: 700;
  font-size: 1em;
}

.step.done .step-num { background: var(--accent); color: #fff; }
.step-head h3 { margin: 0; font-size: 1.1em; }

.step-actions {
  list-style: none;
  margin: 10px 0 0;
  padding: 0 0 0 18px; /* vinkjes onder het stapnummer, tekst onder de staptitel */
  max-width: var(--measure);
}

.step-line {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.step-line:first-child { border-top: 0; }
.step-line.done { color: var(--muted); }
.step-line.done .step-text { text-decoration: line-through; }
.step-line.done .check { background: var(--accent); border-color: var(--accent); }
.step-line.done .hl { background: none; color: inherit; }
.step-bullets { margin: 8px 0 0; padding-left: 22px; }
.step-bullets li { margin-bottom: 4px; }

.hl {
  padding: 0 4px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #92400e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tips { margin-top: 26px; background: var(--accent-soft); border-radius: var(--radius); padding: 16px 22px; }
.tips h2 { margin-top: 0; }
.tips ul { margin: 0; padding-left: 22px; max-width: var(--measure); }
.tips li { margin-bottom: 6px; }
.tips .hl { background: rgba(255, 255, 255, .55); }

.source { margin-top: 20px; font-size: .9rem; color: var(--muted); word-break: break-all; }
.danger-form { margin-top: 28px; }

/* ---------- Video ---------- */
.video {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 0 0 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.video iframe, .video-play {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-play {
  display: grid;
  place-items: center;
  padding: 0;
  background: none;
  cursor: pointer;
}

.video-play img { width: 100%; height: 100%; object-fit: cover; }

.video-icon {
  position: absolute;
  display: grid;
  place-items: center;
  width: 68px;
  height: 48px;
  padding-left: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 1.5rem;
}

.video-play:hover .video-icon { background: #c00; }

/* ---------- Fotogalerij ---------- */
.photo-section { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 24px; }
.photo-section h2 { font-size: 1.15rem; margin: 0 0 14px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  align-items: start;
}

.photo {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.photo.is-cover { border-color: var(--accent); }

.photo-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  font-size: .82rem;
}

.photo-badge { color: var(--accent); font-weight: 600; }

.link-btn {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover { color: var(--accent); }
.link-btn.danger { font-size: 1.1rem; text-decoration: none; color: #b91c1c; }

.photo-add { grid-column: span 2; }

.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  aspect-ratio: 2 / 1;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.photo-drop:hover { border-color: var(--accent); color: var(--accent); }
.photo-drop .plus { font-size: 1.8rem; line-height: 1; }
.photo-drop .hint { font-size: .88rem; }

.photo-url { display: flex; gap: 8px; margin-top: 8px; }

.photo-url input {
  flex: 1;
  min-width: 0;
  padding: 9px 14px;
  font: inherit;
  font-size: .9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  background: rgba(0, 0, 0, .88);
}

.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 92vh; object-fit: contain; border-radius: 8px; }

.lb-close, .lb-nav {
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.lb-nav { width: 44px; height: 44px; font-size: 1.8rem; flex: 0 0 auto; }
.lb-close { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; font-size: 1.5rem; }

/* ---------- Bewerken ---------- */
.editor { max-width: 820px; }

.edit-form textarea {
  width: 100%;
  padding: 16px;
  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  resize: vertical;
}

.edit-actions { margin-top: 14px; }
.error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 10px; }
.help { margin-top: 26px; color: var(--muted); }
.help summary { cursor: pointer; }

.help pre {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-size: .88rem;
  color: var(--ink);
}

/* ---------- Mobiel: grotere raakvlakken tijdens het koken ---------- */
@media (max-width: 900px) {
  :root { --fs-base: 19px; --lh: 1.7; }
  .recipe-grid { grid-template-columns: 1fr; gap: 24px; }
  .ingredients { position: static; }
  .toolbar { top: 57px; }
  .ing { min-height: 44px; align-items: center; padding: 10px 0; }
  .ing-mini { min-height: 40px; padding: 8px 14px; }
  .step { padding: 14px 16px 16px; }
  .step-actions { padding-left: 0; }
  .step-line { min-height: 44px; padding: 12px 0; }
  .wrap { padding: 18px 14px 60px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .photo-add { grid-column: 1 / -1; }
  .photo-drop { aspect-ratio: 3 / 1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --card: #221f18;
    --ink: #f1ece2;
    --muted: #a8a196;
    --line: #3a352b;
    --accent: #f59e0b;
    --accent-soft: #3a2c12;
  }
  .topbar { background: rgba(23, 21, 15, .92); }
  .toolbar { background: linear-gradient(var(--bg) 80%, rgba(23, 21, 15, 0)); }
  .meta-pill { background: #2c281f; }
  .card-media { background: linear-gradient(140deg, #2a251b, #201c15); }
  .tag { color: #fcd34d; }
  .hl { color: #fcd34d; }
  .tips .hl { background: rgba(0, 0, 0, .25); }
  .step-num { color: #fcd34d; }
  .btn-danger { background: var(--card); border-color: #7f1d1d; color: #fca5a5; }
  .error { background: #7f1d1d; color: #fee2e2; }
}
