/* CookNow — phone-first styles */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #26201a;
  --muted: #8d8175;
  --line: #ece2d4;
  --chip: #ffffff;
  --acc: #e4572e;
  --acc-soft: #fdeae3;
  --acc-ink: #ffffff;
  --ok: #1e8a52;
  --ok-bg: #e3f4ea;
  --warn: #a05e10;
  --warn-bg: #fbf0dd;
  --shadow: 0 1px 3px rgba(60, 40, 20, .07), 0 4px 14px rgba(60, 40, 20, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171310;
    --card: #211c17;
    --ink: #f2ece3;
    --muted: #9c8f80;
    --line: #322a22;
    --chip: #262019;
    --acc: #f0663c;
    --acc-soft: #3a221a;
    --acc-ink: #fff7f4;
    --ok: #52c98a;
    --ok-bg: #1d2f25;
    --warn: #e0a353;
    --warn-bg: #33281a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

html { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overscroll-behavior-y: none;
}
section { max-width: 640px; margin: 0 auto; padding: 0 16px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* ---------- hero ---------- */
.hero { padding: calc(14px + env(safe-area-inset-top)) 2px 10px; }
.hero h1 { font-size: 24px; letter-spacing: -.3px; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }

/* ---------- search ---------- */
.searchwrap {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 8px 0 10px;
  background: var(--bg);
}
.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  box-shadow: var(--shadow);
}
.searchbox:focus-within { border-color: var(--acc); }
.searchbox .mag { font-size: 15px; opacity: .55; }
#q {
  flex: 1; border: 0; outline: none; background: none; color: var(--ink);
  font-size: 17px; padding: 13px 0; min-width: 0;
}
#q::placeholder { color: var(--muted); }
.qclear {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--line); color: var(--muted);
  font-size: 13px; flex: none;
}
.sugg {
  position: absolute; left: 0; right: 0; top: calc(100% - 4px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(40, 25, 10, .16);
  overflow: hidden;
}
.sugg button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.sugg button:last-child { border-bottom: 0; }
.sugg button:active { background: var(--acc-soft); }
.sugg .cat { margin-left: auto; color: var(--muted); font-size: 12.5px; flex: none; }
.sugg .added { color: var(--ok); font-size: 13px; margin-left: auto; flex: none; font-weight: 600; }
.sugg .none { padding: 12px 14px; color: var(--muted); font-size: 14.5px; }

/* ---------- selected ingredients ---------- */
.mine { padding: 2px 0 4px; }
.minehead {
  display: flex; align-items: baseline; gap: 8px;
  margin: 4px 0 8px;
}
.minehead h3 { font-size: 15px; font-weight: 650; }
.minehead .clear { margin-left: auto; color: var(--acc); font-size: 14px; font-weight: 600; padding: 4px 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-sel {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--acc); color: var(--acc-ink);
  border-radius: 999px;
  padding: 7px 8px 7px 12px;
  font-size: 15px; font-weight: 550;
  animation: pop .18s ease-out;
}
.chip-sel .x {
  width: 21px; height: 21px; border-radius: 50%;
  background: rgba(255,255,255,.25); color: var(--acc-ink);
  font-size: 12px; line-height: 21px; text-align: center; flex: none;
}
@keyframes pop { from { transform: scale(.85); opacity: .4; } }

.basics {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  margin: 12px 0 2px;
  padding: 10px 12px;
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  font-size: 14px; color: var(--muted); text-align: left;
}
.basics .tick {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  font-size: 13px; color: transparent;
  transition: all .12s;
}
.basics.on .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.basics.on { color: var(--ink); }
.basics b { font-weight: 600; }

/* ---------- category browser ---------- */
.browse { padding-top: 10px; }
.cats {
  display: flex; gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px 10px;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--chip);
  border: 1.5px solid var(--line);
  font-size: 14.5px; font-weight: 550; color: var(--muted);
  white-space: nowrap;
}
.cats button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.cats button .n { opacity: .6; font-size: 12.5px; margin-left: 3px; }

.grid { display: flex; flex-wrap: wrap; gap: 9px; padding-bottom: 18px; }
.ing {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px 9px 11px;
  background: var(--chip);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 15px; font-weight: 500;
  transition: transform .08s;
}
.ing:active { transform: scale(.94); }
.ing.on {
  background: var(--acc-soft);
  border-color: var(--acc);
  color: var(--acc);
  font-weight: 600;
}
.ing.on::after { content: "✓"; font-size: 12.5px; font-weight: 800; }

/* ---------- bottom CTA ---------- */
.ctaspace { height: 92px; }
.cta {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(92%, 600px);
  background: var(--acc); color: var(--acc-ink);
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 17px; font-weight: 700;
  box-shadow: 0 6px 22px rgba(200, 60, 20, .35);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  z-index: 40;
  transition: transform .1s;
}
.cta:active { transform: translateX(-50%) scale(.98); }
.cta .sub { font-weight: 500; font-size: 14.5px; opacity: .85; }
.cta .arr { font-weight: 400; opacity: .9; }

/* ---------- top bar (results / detail) ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.back {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--line);
  font-size: 24px; line-height: 1;
  display: grid; place-items: center;
  padding-bottom: 3px;
}
.bartext { min-width: 0; }
.bartext h2 { font-size: 19px; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bartext p { margin: 0; font-size: 13.5px; color: var(--muted); }
.editbtn {
  margin-left: auto;
  color: var(--acc); font-weight: 650; font-size: 15px;
  padding: 8px 4px;
}

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; padding: 4px 0 12px; }
.filters button {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--chip);
  font-size: 14px; font-weight: 550; color: var(--muted);
}
.filters button.on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }

/* ---------- results ---------- */
.results { padding-bottom: 40px; }
.ghead {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 10px;
  font-size: 15px; font-weight: 700;
}
.ghead:first-child { margin-top: 4px; }
.ghead .pill {
  font-size: 12.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px;
}
.ghead.ready .pill { background: var(--ok-bg); color: var(--ok); }
.ghead.close .pill { background: var(--warn-bg); color: var(--warn); }

.rcard {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.rcard:active { transform: scale(.985); }
.rcard .tile {
  width: 52px; height: 52px; flex: none;
  border-radius: 13px;
  background: var(--acc-soft);
  display: grid; place-items: center;
  font-size: 27px;
}
.rcard .body { min-width: 0; flex: 1; }
.rcard .name { font-size: 16.5px; font-weight: 650; letter-spacing: -.2px; }
.rcard .meta { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.rcard .need { font-size: 13.5px; color: var(--warn); margin-top: 4px; }
.rcard .need b { font-weight: 650; }
.rcard .have-all { font-size: 13.5px; color: var(--ok); font-weight: 600; margin-top: 4px; }
.rcard .go { color: var(--muted); font-size: 20px; flex: none; opacity: .5; }

.morebtn {
  width: 100%;
  padding: 13px;
  margin-top: 8px;
  border-radius: 14px;
  border: 1.5px dashed var(--line);
  color: var(--muted); font-size: 15px; font-weight: 600;
}
.rempty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 15.5px; }
.rempty .big { font-size: 40px; margin-bottom: 10px; }
.rempty button { color: var(--acc); font-weight: 650; margin-top: 12px; font-size: 16px; }

/* ---------- detail ---------- */
.detail { padding-bottom: 56px; }
.dhead { text-align: center; padding: 6px 0 4px; }
.dhead .demoji {
  width: 84px; height: 84px; margin: 0 auto;
  border-radius: 24px;
  background: var(--acc-soft);
  display: grid; place-items: center;
  font-size: 46px;
}
.dhead h2 { font-size: 24px; letter-spacing: -.4px; margin-top: 12px; }
.dmeta {
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
}
.dmeta span {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13.5px; color: var(--muted); font-weight: 550;
}
.havebar {
  margin: 16px 0 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.havebar .txt { font-size: 14px; font-weight: 650; display: flex; justify-content: space-between; }
.havebar .txt .miss { color: var(--warn); font-weight: 600; }
.havebar .txt .all { color: var(--ok); }
.havebar .track {
  height: 6px; border-radius: 3px;
  background: var(--line); margin-top: 9px; overflow: hidden;
}
.havebar .fill { height: 100%; border-radius: 3px; background: var(--ok); transition: width .3s; }

.dsec { margin-top: 20px; }
.dsec h3 { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.ilist { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.irow {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15.5px;
}
.irow:last-child { border-bottom: 0; }
.irow .st { flex: none; width: 22px; text-align: center; font-size: 14px; }
.irow.have .st { color: var(--ok); font-weight: 800; }
.irow.miss { background: var(--warn-bg); }
.irow.miss .st { color: var(--warn); }
.irow .iname { font-weight: 550; }
.irow .qty { margin-left: auto; color: var(--muted); font-size: 13.5px; text-align: right; flex: none; max-width: 45%; }
.irow.opt .iname::after { content: " (optional)"; color: var(--muted); font-weight: 400; font-size: 13px; }
.irow.miss .tag {
  flex: none; font-size: 11.5px; font-weight: 700; color: var(--warn);
  border: 1px solid var(--warn); border-radius: 999px; padding: 1px 7px;
  margin-left: 8px;
}
.basicsnote { color: var(--muted); font-size: 13.5px; margin: 8px 2px 0; }

.steps { counter-reset: step; }
.steps li {
  list-style: none;
  display: flex; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 16px; line-height: 1.5;
  cursor: pointer;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--acc-soft); color: var(--acc);
  font-size: 14px; font-weight: 700;
  display: grid; place-items: center;
  margin-top: 1px;
}
.steps li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(140,120,100,.5); }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.stephint { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }
ol.steps { margin: 0; padding: 0; }

/* ---------- photo scan ---------- */
.scanbtn {
  font-size: 19px; flex: none;
  padding: 8px 2px 8px 10px;
  border-left: 1px solid var(--line);
  opacity: .85;
}
.scan {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 12, 6, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.scansheet {
  width: min(100%, 640px);
  max-height: 88vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .28);
  animation: sheetup .22s ease-out;
}
@keyframes sheetup { from { transform: translateY(24px); opacity: .6; } }
.scanhead { display: flex; align-items: center; margin-bottom: 8px; }
.scanhead h3 { font-size: 17px; }
.scanclose {
  margin-left: auto; width: 32px; height: 32px; border-radius: 50%;
  background: var(--line); color: var(--muted); font-size: 14px;
}
.scanintro { color: var(--muted); font-size: 14.5px; margin: 2px 0 12px; }
.scanacts { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.scanacts button {
  padding: 13px; border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 16px; font-weight: 600;
}
.scanacts .primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.scanacts .primary:disabled { opacity: .45; }
.scanphoto {
  width: 100%; max-height: 36vh; object-fit: contain;
  border-radius: 14px; background: #000;
}
.scanwait {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); padding: 18px 4px; font-size: 15px;
}
.spin {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--line); border-top-color: var(--acc);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scanerr { color: var(--warn); font-size: 15px; padding: 10px 2px 0; }
.scanbadge {
  display: inline-block; margin-top: 10px;
  font-size: 12.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.scanbadge.demo { background: var(--warn-bg); color: var(--warn); }
.scanbody h4 { font-size: 15px; margin: 12px 0 8px; }
.scangrid { padding-bottom: 2px; }
.scanown { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }

/* pinned photo strip (offline / manual path) */
.pin {
  position: relative;
  display: flex; gap: 10px; align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  margin: 4px 0 8px;
  box-shadow: var(--shadow);
}
.pin img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; flex: none; }
.pin.open { flex-direction: column; align-items: stretch; }
.pin.open img { width: 100%; height: auto; max-height: 42vh; object-fit: contain; background: #000; }
.pintxt { font-size: 13.5px; color: var(--muted); }
.pin .x {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, .38); color: #fff; font-size: 12px;
}

/* toast */
#toast {
  position: fixed; left: 50%; z-index: 70;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600;
  max-width: 92%; text-align: center;
  opacity: 0; pointer-events: none;
  transition: all .22s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 480px) {
  .hero h1 { font-size: 27px; }
}
