:root {
  --bg: #faf7f2; --card: #fff; --ink: #2b2722; --muted: #8a8178;
  --accent: #c2410c; --accent-soft: #fde8dc; --line: #eee6da; --ok: #15803d;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
header { padding: 28px 20px 8px; max-width: 720px; margin: 0 auto; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 60px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 18px 20px; margin: 14px 0; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.hint, .count { color: var(--muted); font-size: 13px; }
.count { font-weight: 400; }
input[type=text], #perishables {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; margin: 8px 0; background: #fffdfa;
}
button {
  font: inherit; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; transition: .15s;
}
button:hover { background: #f6f1ea; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.status { color: var(--ok); font-size: 14px; }

.photoRow { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.photoBtn {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px;
  border: 1px solid var(--accent-soft); background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; cursor: pointer; font-weight: 600;
}
.photoBtn:hover { filter: brightness(.98); }

.storeBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.storeBtns .photoBtn { justify-content: center; }
.glance { display: grid; gap: 6px; margin: 6px 0 12px; }
.glance .gl { font-size: 14px; padding: 8px 11px; border-radius: 9px; background: #fffdfa; border: 1px solid var(--line); line-height: 1.5; }
.glance .gl.fresh { background: var(--accent-soft); border-color: var(--accent); }
.glance .gl b { margin-right: 4px; }
.lvlBad { color: #c0341d; font-weight: 700; white-space: nowrap; }
.lvlOk { color: #1d8a3a; font-weight: 700; }
.lvlMeh { color: #999; white-space: nowrap; }

.week { display: grid; gap: 8px; margin-top: 10px; }
.meal {
  display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffdfa;
}
.meal .slot { color: var(--muted); font-size: 13px; }
.meal .name { font-weight: 600; }
.reroll {
  width: 34px; height: 34px; padding: 0; border-radius: 8px; font-size: 16px;
  color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft);
}

.list .cat label, .list .cat .li {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px dashed var(--line);
}
.list .qty { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; }
.list em { color: var(--accent); font-style: normal; font-size: 12px; }
.list a.buy { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.list a.buy:hover { color: var(--accent); }
#copyBtn { margin-top: 4px; }
.shopBtn { color: var(--accent); font-weight: 600; text-decoration: none; padding: 11px 4px; }

/* recipe editor */
.redit { display: grid; gap: 10px; margin-top: 8px; }
.fld { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.fld.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.fld input[type=text], .redit input:not([type]) { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fffdfa; }
.ingHead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
.ingRow { display: grid; grid-template-columns: 64px 64px 1fr auto; gap: 6px; margin: 4px 0; }
.ingRow input { padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; background: #fffdfa; width: 100%; }
.mini { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.iDel { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.redit textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fffdfa; font-family: inherit; resize: vertical; }

/* recipe library */
.libHead { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; }
.lib { display: grid; gap: 8px; }
.libItem {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fffdfa; cursor: pointer;
}
.libItem:hover { background: #f6f1ea; }
.thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; flex: none; }
.thumb.noimg { display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--accent-soft); }
.libName { display: flex; flex-direction: column; font-weight: 600; }
.libTags { color: var(--muted); font-size: 12px; font-weight: 400; }

/* recipe card overlay */
#cardOverlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(43,39,34,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto;
}
/* the ID selector above out-specificities the [hidden] UA rule, so hide it explicitly */
#cardOverlay[hidden] { display: none; }
#card {
  background: var(--card); border-radius: 18px; max-width: 560px; width: 100%;
  padding: 0 22px 26px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.cardClose {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: none; font-size: 16px; cursor: pointer; z-index: 2;
}
.cardImg { width: calc(100% + 44px); margin: 0 -22px 4px; max-height: 320px; object-fit: cover; border-radius: 18px 18px 0 0; display: block; }
.cardName { margin: 16px 0 2px; font-size: 24px; letter-spacing: -.02em; }
.cardMeta { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
#card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.cardIngs { margin: 0; padding-left: 20px; }
.cardIngs li { padding: 3px 0; }
.cardSteps { margin: 0; padding-left: 22px; }
.cardSteps li { padding: 6px 0; line-height: 1.55; }
.cardDelete { margin-top: 22px; width: 100%; color: #b91c1c; background: #fff; border-color: #f0c9c9; }
.cardDelete:hover { background: #fdeaea; }

/* staged recipe photos */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.thumbItem { position: relative; }
.thumbItem img { width: 66px; height: 66px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.thumbDel {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%;
  padding: 0; font-size: 12px; line-height: 1; background: var(--accent); color: #fff; border: none;
}
.cardDelete.armed { background: #b91c1c; color: #fff; border-color: #b91c1c; }

/* editable shopping list */
.liDel {
  margin-left: auto; width: 26px; height: 26px; padding: 0; border-radius: 6px;
  font-size: 12px; color: var(--muted); border-color: var(--line); background: #fff; flex: none;
}
.liDel:hover { color: #b91c1c; border-color: #f0c9c9; }
.addItem { display: flex; gap: 8px; margin: 14px 0 4px; }
.addItem input { flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; background: #fffdfa; }
.addItem button { white-space: nowrap; }
.appver { text-align: center; color: var(--muted); font-size: 11px; margin: 24px 0 8px; opacity: .7; }

/* product book (ingredient -> exact REWE product link) */
.list a.buy.linked { border-bottom-style: solid; color: var(--accent); }
.pbook { display: grid; gap: 8px; margin-top: 8px; }
.pbrow { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.pbname { font-weight: 600; font-size: 14px; }
.pblink { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fffdfa; width: 100%; }

/* order toggles */
.orderList { display: grid; gap: 4px; margin: 8px 0 16px; }
.orow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 1px dashed var(--line); }
.oname { font-weight: 600; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d9d2c7; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .slider::before { content: ''; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.ostep { display: flex; align-items: center; gap: 8px; }
.ostep button { width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: 17px; line-height: 1; }
.omult { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
#orderNowBtn { margin-top: 6px; }
.missing { margin: 2px 0 14px; }
.missHead { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.missItems { display: flex; flex-wrap: wrap; gap: 6px; }
.missItem { display: inline-block; padding: 5px 10px; border-radius: 999px; font-size: 13px; background: #fdeaea; color: #b91c1c; border: 1px solid #f0c9c9; }

.orderReady { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.orderReady .rdy { display: inline-block; padding: 5px 10px; border-radius: 999px; font-size: 13px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); font-weight: 600; }
.orderActions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
.orderActions #copyOrder { font-size: 13px; padding: 6px 12px; }
.orderActions .reweLink { font-size: 13px; color: var(--accent); font-weight: 600; }

.cost { margin-top: 6px; }
.costRow {
  display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 10px;
  padding: 8px 2px; border-bottom: 1px dashed var(--line);
}
.costRow b { font-variant-numeric: tabular-nums; font-size: 17px; }
.costRow .costWk { color: var(--muted); font-size: 12px; min-width: 150px; text-align: right; }
.costRow.delta { border-bottom: none; color: var(--accent); }
.costRow.delta b { color: var(--accent); }

.deliv .when { background: var(--accent-soft); color: var(--accent); padding: 12px 14px; border-radius: 10px; margin: 0 0 12px; }
.deliv ul { margin: 0 0 12px; padding-left: 18px; color: var(--ink); }
.deliv ul li { margin: 4px 0; }
.deliv a { color: var(--accent); font-weight: 600; text-decoration: none; }
.deliv .alts { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.deliv .alts a { font-weight: 400; }

.staples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.staple {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 14px; background: #fffdfa;
}
.staple.low { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

@media (max-width: 480px) {
  .meal { grid-template-columns: 96px 1fr auto; }
}
