:root {
  color-scheme: light;
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --ink: #2B2320;
  --muted: #7A6A60;
  --line: #EFE3D6;
  --accent: #D2603A;
  --accent-ink: #A8472A;
  --accent-soft: #FBE7DE;
  --clean: #3F7D4E;
  --clean-soft: #E4F1E6;
  --fun: #A86E00;
  --fun-soft: #FCEFD2;
  --good: #2F7D46;
  --radius: 18px;
  --tap: 52px;
  --shadow: 0 1px 2px rgba(60, 35, 20, .06), 0 6px 18px rgba(60, 35, 20, .07);
  --head: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0; }
a { color: var(--accent-ink); }
button { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- header ---------- */
.top { padding: calc(14px + env(safe-area-inset-top)) 16px 6px; }
.top-in { max-width: 1100px; margin: 0 auto; }
.top h1 { font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 15px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- lane switch ---------- */
.seg { display: flex; background: #F3E8DC; border-radius: 999px; padding: 4px; margin: 6px 0 14px; }
.seg button {
  flex: 1; min-height: 44px; border: 0; border-radius: 999px; background: transparent;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-h h2 { font-size: 21px; }
.section-h .note { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 15px; margin: 0 0 12px; }

/* ---------- recipe cards ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; border: 2px solid transparent; transition: border-color .15s;
}
.card.picked { border-color: var(--accent); }
.photo {
  position: relative; aspect-ratio: 16 / 10; background: linear-gradient(135deg, #F8DCCB, #F6E9C9);
  display: block; width: 100%; border: 0; padding: 0; cursor: pointer;
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .ph {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}
.photo img + .ph { display: none; }
.photo img.broken { display: none; }
.photo img.broken + .ph { display: grid; }
.heart {
  position: absolute; top: 10px; right: 10px; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .92); font-size: 22px; line-height: 46px; cursor: pointer;
  color: #B9A89C; box-shadow: var(--shadow);
}
.heart[aria-pressed="true"] { color: #D83A5A; }
.picked-flag {
  position: absolute; left: 10px; top: 10px; background: var(--accent); color: #fff; font-weight: 800;
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.card-body { padding: 12px 14px 4px; cursor: pointer; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.tag { font-size: 13px; font-weight: 800; border-radius: 999px; padding: 3px 10px; letter-spacing: .02em; }
.tag.clean { background: var(--clean-soft); color: var(--clean); }
.tag.fun { background: var(--fun-soft); color: var(--fun); }
.tag.plain { background: #F3E8DC; color: var(--muted); }
.diff { display: inline-flex; gap: 3px; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.diff i { width: 9px; height: 9px; border-radius: 50%; background: #E6D8CB; display: inline-block; }
.diff i.on { background: var(--accent); }
.card h3 { font-size: 20px; margin: 2px 0 6px; }
.meta { color: var(--muted); font-size: 15px; }
.meta b { color: var(--ink); font-weight: 600; }
.protein { font-size: 14px; margin-top: 6px; color: var(--ink); }
.protein span { white-space: nowrap; }
.card-actions { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; margin-top: auto; }

.btn {
  min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-weight: 800; font-size: 17px; cursor: pointer; padding: 0 18px; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink);
}
.btn.big { width: 100%; min-height: 58px; font-size: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .6; }
.btn.pick[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.btn:focus-visible, .seg button:focus-visible, .heart:focus-visible, .row:focus-visible { outline: 3px solid #2B6CB0; outline-offset: 2px; }

.stepper { display: flex; align-items: center; gap: 10px; background: #FBF3EA; border-radius: 14px; padding: 6px 6px 6px 14px; }
.stepper .lbl { flex: 1; font-size: 15px; }
.stepper .lbl b { display: block; font-size: 16px; }
.stepper button {
  width: var(--tap); height: var(--tap); border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); font-size: 26px; font-weight: 700; cursor: pointer; line-height: 1;
}
.stepper button:disabled { opacity: .35; }

.thumbs { display: flex; gap: 10px; }
.thumbs button {
  flex: 1; min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-size: 24px; cursor: pointer;
}
.thumbs button[aria-pressed="true"].up { background: #E4F1E6; border-color: var(--good); }
.thumbs button[aria-pressed="true"].down { background: #F9E1DC; border-color: #C0492F; }

.empty { background: var(--card); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); box-shadow: var(--shadow); }
.empty b { color: var(--ink); display: block; font-size: 18px; margin-bottom: 4px; }

/* ---------- shopping list ---------- */
.list-tools { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 4px 0 12px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; min-height: 44px; }
.switch input { width: 52px; height: 30px; appearance: none; -webkit-appearance: none; background: #E6D8CB; border-radius: 999px; position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--good); }
.switch input:checked::after { left: 25px; }
.progress { color: var(--muted); font-size: 15px; }
.box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 0 14px; overflow: hidden; }
.box h2 { font-size: 17px; padding: 12px 16px 8px; display: flex; justify-content: space-between; gap: 8px; }
.box h2 small { color: var(--muted); font-weight: 600; font-family: system-ui, sans-serif; font-size: 13px; }
.box.staples { background: #FFFDF8; border: 2px dashed #E6CDB6; box-shadow: none; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 16px;
  border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer;
}
.row .chk {
  flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2.5px solid #CDB8A6;
  display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 17px;
}
.row .txt { flex: 1; min-width: 0; }
.row .nm { font-weight: 650; }
.row .qty { color: var(--muted); font-size: 14px; }
.row .why { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .state { font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 9px; flex: none; }
.row.have .chk { background: #B9A89C; border-color: #B9A89C; }
.row.have .nm, .row.have .qty { text-decoration: line-through; color: #A89A90; }
.row.have .state { background: #F1E9E2; color: var(--muted); }
.row.in_cart .chk { background: var(--good); border-color: var(--good); }
.row.in_cart .state { background: #E4F1E6; color: var(--good); }
.kidtag { font-size: 11px; font-weight: 800; color: var(--fun); background: var(--fun-soft); border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: 2px; }
.row .x { flex: none; width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; color: var(--muted); cursor: pointer; }
.addform { display: flex; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.addform input { flex: 1; min-width: 0; min-height: var(--tap); border-radius: 12px; border: 2px solid var(--line); padding: 0 14px; font-size: 17px; background: #fff; }

/* ---------- print / pdf view ---------- */
.pdf-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.pdf-card ol { padding-left: 22px; margin: 8px 0 14px; }
.pdf-card li { margin: 4px 0; }
.done { background: #E4F1E6; color: var(--good); border-radius: 14px; padding: 12px 14px; font-weight: 700; margin-top: 12px; }

/* ---------- recipe sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(43, 35, 32, .45); }
.sheet-card {
  position: relative; background: var(--bg); width: 100%; max-width: 720px; max-height: 94vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch;
}
@media (min-width: 760px) { .sheet { align-items: center; } .sheet-card { border-radius: 22px; } }
.sheet-x {
  position: sticky; top: 10px; float: right; margin: 10px 10px -56px 0; z-index: 2; width: 46px; height: 46px;
  border-radius: 50%; border: 0; background: rgba(255, 255, 255, .95); font-size: 28px; cursor: pointer; box-shadow: var(--shadow);
}
.sheet .photo { aspect-ratio: 16 / 9; cursor: default; }
.sheet-in { padding: 14px 18px 8px; }
.sheet-in h2 { font-size: 26px; margin: 4px 0 4px; }
.credit { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 10px 0; }
.fact { background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--muted); }
.fact b { display: block; color: var(--ink); font-size: 16px; }
.plate { background: var(--card); border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
.nw { white-space: nowrap; }
.plate h4 { margin: 0 0 4px; font-size: 16px; font-family: var(--head); }
.plate .addon { color: var(--clean); font-weight: 650; font-size: 15px; margin-top: 4px; }
.sheet-in h3 { font-size: 18px; margin: 18px 0 6px; }
.sheet-in ul, .sheet-in ol { padding-left: 22px; margin: 0; }
.sheet-in li { margin: 5px 0; }
.swap del { color: var(--muted); }
.swap ins { text-decoration: none; font-weight: 650; }
.callout { background: var(--fun-soft); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 15px; }
.callout.kids { background: #E8F0FB; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; padding: 8px 18px 0; }

/* ---------- toast + tabs ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 40; max-width: 90vw; font-weight: 600;
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: rgba(255, 252, 247, .97);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px);
}
.tabs a {
  flex: 1; min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; position: relative; gap: 2px;
}
.tabs a .ti { font-size: 22px; line-height: 1; }
.tabs a[aria-current="page"] { color: var(--accent-ink); }
.tabs a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.badge { position: absolute; top: 7px; left: calc(50% + 8px); background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px; }

/* ---------- login ---------- */
.login-body { padding: 0; }
.login { max-width: 380px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top)) 20px 40px; text-align: center; }
.login-icon { border-radius: 18px; box-shadow: var(--shadow); }
.login h1 { font-size: 34px; margin: 14px 0 2px; }
.login form { text-align: left; margin-top: 26px; display: flex; flex-direction: column; gap: 16px; }
.login label { font-weight: 700; display: flex; flex-direction: column; gap: 6px; }
.login input { min-height: 56px; border-radius: 14px; border: 2px solid var(--line); padding: 0 16px; font-size: 18px; background: #fff; }
.login input:focus { border-color: var(--accent); outline: none; }
.err { color: #B3261E; font-weight: 650; margin: 0; }

@media print {
  .tabs, .top, .seg, .list-tools, .addform, .x, .toast { display: none !important; }
  body { background: #fff; padding: 0; }
  .box { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 639px) { .card .photo { aspect-ratio: 2 / 1; } }
.login label.show { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.login label.show input { min-height: 0; width: 22px; height: 22px; padding: 0; }
