:root {
  --bg: #f5f6fa; --card: #fff; --text: #1d2130; --muted: #6b7185; --line: #e3e6ef;
  --accent: #4f7cff; --accent-text: #fff; --danger: #d64545; --ok: #2f9e62;
  --radius: 14px; --shadow: 0 1px 3px rgba(20, 30, 60, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12141b; --card: #1c1f2a; --text: #eceef5; --muted: #9aa0b4; --line: #2c3040; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar h1 { flex: 1; margin: 0; font-size: 20px; }
.back { font-size: 30px; line-height: 1; border: 0; background: none; color: var(--accent); padding: 0 6px 0 0; }
.who { font-size: 14px; color: var(--muted); }
main { max-width: 640px; width: 100%; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 24px); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.tile .icon { font-size: 32px; }
.tile .name { font-weight: 600; }
.tile .desc { font-size: 13px; color: var(--muted); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input, select { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
input[type=color] { padding: 2px; height: 44px; }
.btn { display: inline-block; text-align: center; text-decoration: none; box-sizing: border-box; font: inherit; font-weight: 600; padding: 12px 16px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-text); cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.block { width: 100%; margin-top: 16px; }
button:disabled { opacity: .5; }
.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.list > * + * { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
h2 { font-size: 18px; margin: 0 0 8px; }
a { color: var(--accent); }

/* ---- Computer layout (wide screens) ---- */
#side { display: none; }
.narrow { max-width: 560px; }
.cols { display: grid; gap: 12px; }
.cols > .card { margin-bottom: 0; }
@media (min-width: 900px) {
  .layout { display: flex; min-height: calc(100vh - 60px); }
  body.signed-in #side:not([hidden]) { display: flex; flex-direction: column; gap: 2px; width: 230px; flex: none;
    padding: 16px 12px; border-right: 1px solid var(--line); position: sticky; top: 60px; height: calc(100vh - 60px); }
  #side .brand { font-weight: 700; padding: 4px 12px 14px; }
  #side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
  #side a:hover { background: var(--line); }
  #side a.on { background: var(--accent); color: var(--accent-text); }
  #side .icon { width: 22px; text-align: center; }
  #side .side-foot { margin-top: auto; padding: 12px; }
  #side .side-foot a { padding: 0; color: var(--accent); }
  #side .side-foot a:hover { background: none; text-decoration: underline; }
  body.signed-in main { max-width: 1100px; padding: 24px 32px; margin: 0; }
  body.signed-in .back, body.signed-in .who { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (min-width: 900px) {
  body:not(.signed-in) main { max-width: 440px; margin: 40px auto; }
}

/* ---- Family crest ---- */
.crest { text-align: center; margin: 4px 0 16px; }
.crest img { width: 150px; height: auto; }
.crest .motto { font-family: Georgia, "Times New Roman", serif; letter-spacing: .12em; text-transform: uppercase;
  font-size: 12px; color: var(--muted); margin-top: 6px; }
#side .brand { text-align: center; }
#side .brand img { width: 96px; height: auto; display: block; margin: 0 auto 8px; }

/* ---- Shared pieces for tools: tabs, chips, badges, full-screen overlay ---- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; white-space: nowrap; font-size: 15px; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: 12px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { margin: 0; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--text); font-size: 15px; cursor: pointer; }
.chips input { width: auto; margin: 0; }
.chips label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge.todo { background: var(--line); color: var(--muted); }
.badge.submitted { background: #fff1d6; color: #8a5a00; }
.badge.approved { background: #dcf3e5; color: #1f7a48; }
.badge.rejected { background: #fde2e2; color: #a52a2a; }
.badge.excused, .badge.missed { background: var(--line); color: var(--muted); }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.big-money { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.section-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.daynav button { font-size: 22px; width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; }
.overlay { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.overlay video, .overlay img.shot { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.overlay .bar { display: flex; gap: 12px; justify-content: center; align-items: center;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); background: #000; color: #fff; }
.overlay .shutter { width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; background: #fff;
  box-shadow: inset 0 0 0 3px #000; cursor: pointer; }
.overlay .hint { color: #ccc; text-align: center; padding: calc(env(safe-area-inset-top) + 12px) 16px 8px; font-size: 14px; }
.thumb { width: 100%; max-height: 360px; object-fit: cover; border-radius: 10px; background: var(--line); display: block; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { flex: 1; }
textarea { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
@media (prefers-color-scheme: dark) {
  .badge.submitted { background: #4a3a10; color: #ffd27a; }
  .badge.approved { background: #143d27; color: #7be0a6; }
  .badge.rejected { background: #4a1c1c; color: #ff9d9d; }
}
.scan-frame { position: absolute; left: 12%; right: 12%; top: 35%; height: 30%; border: 3px solid rgba(255,255,255,.85);
  border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.overlay .bar input { background: #222; color: #fff; border-color: #444; }
.recipe-img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: var(--line); }
.recipe-card { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); }
.recipe-card img, .recipe-card .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--line);
  display: grid; place-items: center; font-size: 26px; }
.check-row { display: flex; align-items: flex-start; gap: 12px; }
.check-row input[type=checkbox] { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check-row.done .grow > div:first-child { text-decoration: line-through; color: var(--muted); }
.iconbtn { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 160px; }
.meal { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.meal .slot { font-size: 12px; color: var(--muted); width: 64px; flex: none; text-transform: capitalize; }
.today-mark { border-color: var(--accent); }
ol.steps { padding-left: 20px; margin: 0; } ol.steps li { margin-bottom: 8px; }
ul.ings { padding-left: 18px; margin: 0; } ul.ings li { margin-bottom: 4px; }
.warn { background: #fff4d6; color: #7a5200; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .warn { background: #3d3214; color: #ffd98a; } }
@media (min-width: 900px) { .cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; } .cols-3 > .card { margin: 0; } }

/* ---- Store product rows (Smith's cart review) ---- */
.product-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line, #e5e5e5); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; font: inherit; color: inherit; }
.product-row:last-child { border-bottom: 0; }
.product-row img, .product-row .noimg { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; display: grid; place-items: center; }
.product-row input[type=checkbox] { width: auto; margin: 0; }
.product-row input[type=number] { margin: 0; }
.product-row.skipped { opacity: .5; }
.product-row.pick { cursor: pointer; }
.product-row .badge { margin-left: 6px; }
button.check-row.store { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line, #e5e5e5); font: inherit; color: inherit; cursor: pointer; }
