:root {
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-2: #f3ede6;
  --text: #2a2420;
  --muted: #786c62;
  --border: #e6ddd2;
  --accent: #c2562f;
  --accent-ink: #ffffff;
  --accent-soft: #f7e3d9;
  --good: #3b8d5a;
  --danger: #b8323a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 14px;
  --nav-w: 210px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1613; --surface: #25201b; --surface-2: #2f2822; --text: #f2ebe3; --muted: #a8998b;
    --border: #3b322a; --accent: #e07a52; --accent-ink: #1a1613; --accent-soft: #43281c;
    --good: #5cb27c; --danger: #e0626a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1613; --surface: #25201b; --surface-2: #2f2822; --text: #f2ebe3; --muted: #a8998b;
  --border: #3b322a; --accent: #e07a52; --accent-ink: #1a1613; --accent-soft: #43281c;
  --good: #5cb27c; --danger: #e0626a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* No zooming: "manipulation" turns off double-tap-to-zoom (and the tap delay that comes with it).
   Pinch zoom is blocked in js/app.js and by the viewport meta tag. */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
/* The app always fits the screen's width, so the page itself never moves sideways
   (strips like shopping-list tabs still scroll inside themselves). */
body { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- form controls ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; min-height: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
label small { font-weight: 400; }
.label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row > input { flex: 1; }
.row.center { justify-content: center; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .85rem; }
.btn.big { min-height: 52px; padding: 12px 22px; font-size: 1.05rem; }
.btn.icon { padding: 0; width: 44px; font-size: 1.3rem; }
.btn.icon.small { width: 36px; }
.file-btn { font-weight: 600; font-size: .95rem; }

/* ---------- gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 28px; max-width: 420px; width: 100%; text-align: center; }
.gate-card form { text-align: left; }
.gate-logo { width: 72px; height: 72px; margin-bottom: 12px; }
.gate-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: .92rem; text-align: left; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.nav {
  position: fixed; z-index: 20; background: var(--surface); border-color: var(--border);
  display: flex;
}
.brand { display: none; }
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .72rem; font-weight: 600;
  padding: 8px 2px; cursor: pointer; border-radius: 10px;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--accent); }
main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }

@media (max-width: 799px) {
  .nav { left: 0; right: 0; bottom: 0; border-top: 1px solid var(--border); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
}
@media (min-width: 800px) {
  .nav { top: 0; bottom: 0; left: 0; width: var(--nav-w); flex-direction: column; gap: 4px; padding: 18px 12px; border-right: 1px solid var(--border); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px 18px; }
  .brand img { width: 34px; height: 34px; }
  .nav-btn { flex: none; flex-direction: row; gap: 12px; font-size: .98rem; padding: 11px 12px; }
  .nav-btn:hover { background: var(--surface-2); color: var(--text); }
  .nav-btn.active { background: var(--accent-soft); color: var(--accent); }
  main { margin-left: var(--nav-w); padding: 28px 32px 40px; max-width: none; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; margin-right: auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty.small { padding: 18px 8px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.chips.small { margin: 8px 0; gap: 6px; }
.chip {
  font: inherit; font-size: .88rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer;
}
.chips.small .chip { min-height: 32px; padding: 4px 11px; font-size: .82rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.static { cursor: default; background: var(--surface-2); display: inline-flex; align-items: center; }

/* ---------- home / wall ---------- */
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.clock { font-size: 2.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.today-date { color: var(--muted); font-size: 1.05rem; margin-top: 6px; }
.home-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1400px) { .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.home-grid > .card { min-width: 0; }
.slot-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--border); }
.slot-row:first-of-type { border-top: 0; }
.slot-label { color: var(--muted); font-weight: 600; font-size: .9rem; padding-top: 6px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 32px; }
.meal-chip {
  font: inherit; font-weight: 600; font-size: .95rem; text-align: left; background: var(--accent-soft); color: var(--text);
  border: 0; border-radius: 10px; padding: 6px 12px; cursor: pointer;
}
.meal-chip.text { background: var(--surface-2); cursor: default; }
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); align-items: center; }
.upcoming li:first-child { border-top: 0; }
.up-day { font-weight: 700; display: flex; flex-direction: column; line-height: 1.15; }
.up-day small { color: var(--muted); font-weight: 500; }
.slot-tag { font-size: .7rem; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.store-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.store-tile {
  font: inherit; color: var(--text); text-align: left; cursor: pointer; background: var(--surface-2);
  border: 0; border-left: 6px solid var(--c); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.st-name { font-weight: 700; }
.st-count { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.st-label { color: var(--muted); font-size: .85rem; }

.wall-exit { display: none; }
body.wall .nav { display: none; }
body.wall main { margin-left: 0; padding: 32px 40px; max-width: none; }
body.wall .wall-exit { display: inline-flex; position: fixed; top: 14px; right: 14px; opacity: .35; z-index: 30; }
body.wall .wall-exit:hover, body.wall .wall-exit:focus-visible { opacity: 1; }
body.wall main { padding: 24px 28px; }
body.wall .clock { font-size: 4.2rem; }
body.wall .today-date { font-size: 1.4rem; }
body.wall .home-head { margin-bottom: 14px; }
body.wall .card { padding: 16px; }
body.wall .card h2 { font-size: 1.35rem; }
body.wall .meal-chip, body.wall .up-day, body.wall .ev-title, body.wall .chore-title { font-size: 1.1rem; }
body.wall .slot-row { grid-template-columns: 96px 1fr; }
body.wall .st-count { font-size: 2rem; }
body.wall .todo .x { display: none; }
@media (min-width: 1000px) {
  body.wall .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  body.wall .store-tiles { grid-template-columns: 1fr 1fr; }
}

/* ---------- meal plan ---------- */
.week-nav { display: flex; align-items: center; gap: 6px; }
.wk-label { font-weight: 700; min-width: 140px; text-align: center; }
.week { display: grid; gap: 12px; }
@media (min-width: 640px) { .week { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
@media (min-width: 1560px) { .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; } }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 6px; }
.dow { font-weight: 700; }
.dnum { color: var(--muted); font-size: .85rem; }
.is-today .dow { color: var(--accent); }
.slot { border-top: 1px solid var(--border); padding: 6px 0; }
.slot-top { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.add-meal { background: none; border: 0; color: var(--muted); width: 36px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.add-meal:hover { background: var(--surface-2); color: var(--accent); }
.add-meal svg { width: 18px; height: 18px; }
.meal { display: flex; align-items: center; gap: 4px; background: var(--accent-soft); border-radius: 8px; margin-top: 4px; }
.meal-title { flex: 1; font: inherit; font-size: .9rem; font-weight: 600; color: var(--text); background: none; border: 0; text-align: left; padding: 6px 8px; cursor: pointer; overflow-wrap: break-word; min-width: 0; }
span.meal-title { cursor: default; }
.x { background: none; border: 0; color: var(--muted); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; flex: none; }
.x:hover { color: var(--danger); background: var(--surface-2); }
.x svg { width: 16px; height: 16px; }

/* ---------- recipes ---------- */
.search { max-width: 520px; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .recipe-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.recipe-card {
  font: inherit; color: var(--text); text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0; overflow: hidden; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.recipe-card:hover { border-color: var(--accent); }
.thumb {
  aspect-ratio: 16 / 10; position: relative; display: grid; place-items: center;
  background: hsl(var(--h) 45% 82%); color: hsl(var(--h) 35% 30%); font-size: 2.2rem; font-weight: 800;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .thumb { background: hsl(var(--h) 25% 26%); color: hsl(var(--h) 45% 78%); } }
:root[data-theme="dark"] .thumb { background: hsl(var(--h) 25% 26%); color: hsl(var(--h) 45% 78%); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rc-body { padding: 10px 12px 12px; }
.rc-title { font-weight: 700; }
.rc-meta { color: var(--muted); font-size: .82rem; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-between; }
.rc-time { white-space: nowrap; }
.star { color: #d99a1e; }
/* repeating meals, new-recipe spots, auto-plan */
.mp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meal.repeat { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.meal .x.rep { font-size: 1.15rem; font-weight: 700; color: var(--accent); width: 44px; height: 36px; }
.meal.new { background: transparent; border: 1.5px dashed var(--accent); }
.meal.new .meal-title { color: var(--accent); }
.mp-repeat { margin: 4px 0 10px; }
.mp-repeat .chips { margin: 4px 0 0; }
.stack-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.stack-actions .btn { justify-content: center; min-height: 44px; }
.ap-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.ap-nums input { width: 100%; }
.ap-count { margin: 6px 0; }
.ap-recipes { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 4px 12px; }
#ap-pool-tabs { margin-bottom: 8px; }
.pv-body { max-height: 58vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.pv-week { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 4px; }
.pv-week:first-child { margin-top: 4px; }
.pv-day { border-top: 1px solid var(--border); padding: 6px 0; }
.pv-date { font-weight: 700; font-size: .9rem; margin-bottom: 2px; }
.pv-row { display: flex; align-items: center; gap: 6px; min-height: 40px; padding-left: 4px; }
.pv-slot { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; width: 72px; flex: none; }
.pv-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: break-word; }
.pv-row .x { width: 40px; height: 40px; font-size: 1.1rem; }
.pv-row.old .pv-title, .pv-row.removed .pv-title { color: var(--muted); font-weight: 400; }
.pv-row.old { opacity: .7; }
.pv-note { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.pv-row.new .pv-title { color: var(--accent); }
.pv-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; }
.r-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.r-tools .search { flex: 1 1 150px; min-width: 0; }
.r-tools .seg-btn { min-height: 44px; }
/* simple list view */
.recipe-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.rl-group { padding: 12px 6px 6px; }
.rl-head { font-size: .8rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 10px 4px; display: flex; gap: 8px; align-items: center; }
.rl-count { font-weight: 700; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: .75rem; letter-spacing: 0; }
.rl-items { list-style: none; margin: 0; padding: 0; }
.rl-items li + li { border-top: 1px solid var(--border); }
.rl-row {
  font: inherit; color: var(--text); background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 10px; min-height: 44px; border-radius: 8px;
}
.rl-row:hover { background: var(--surface-2); }
.rl-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: break-word; }
.rl-time { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.detail-img { width: calc(100% + 48px); margin: -24px -24px 16px; max-height: 280px; object-fit: cover; display: block; border-radius: 18px 18px 0 0; }
.detail-head { display: flex; align-items: flex-start; gap: 10px; padding-right: 40px; }
.detail-head h2 { font-size: 1.5rem; margin: 0; flex: 1; }
.fav-btn { background: none; border: 1px solid var(--border); border-radius: 10px; width: 44px; height: 44px; font-size: 1.3rem; color: var(--muted); cursor: pointer; flex: none; }
.fav-btn.on { color: #d99a1e; border-color: #d99a1e; }
.meta-row { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: .9rem; margin-top: 8px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.detail-cols { display: grid; gap: 8px 28px; }
@media (min-width: 700px) { .detail-cols { grid-template-columns: 1fr 1.4fr; } }
.ingredients { padding-left: 1.2em; margin: 0; }
.ingredients li { padding: 4px 0; }
.steps { padding-left: 1.4em; margin: 0; }
.steps li { padding: 5px 0; }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 0; }

/* ---------- lists ---------- */
.store-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 4px; scrollbar-width: thin; }
.store-tab {
  font: inherit; font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 8px 8px 16px; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  box-shadow: inset 4px 0 0 var(--c);
}
.store-tab.on { background: var(--c); border-color: var(--c); color: #fff; box-shadow: none; }
.store-tab .count { background: var(--surface-2); color: var(--text); border-radius: 999px; min-width: 26px; padding: 1px 8px; font-size: .82rem; text-align: center; }
.store-tab.on .count { background: rgba(255,255,255,.25); color: #fff; }
.add-item { display: flex; gap: 8px; margin: 6px 0 14px; max-width: 640px; }
.add-item #ai-name { flex: 1; }
.add-item .qty { width: 90px; flex: none; }
.add-item .btn { width: 48px; padding: 0; flex: none; }
.items { list-style: none; margin: 0; padding: 0; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); padding: 4px 6px; }
.item:first-child { border-top: 0; }
.check {
  width: 44px; height: 44px; flex: none; background: none; border: 0; cursor: pointer; display: grid; place-items: center; color: var(--accent-ink);
}
.check::before { content: ""; grid-area: 1 / 1; width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 7px; }
.check svg { grid-area: 1 / 1; width: 16px; height: 16px; stroke-width: 3; z-index: 1; }
.item.done .check::before { background: var(--good); border-color: var(--good); }
.item-main { flex: 1; min-width: 0; padding: 8px 4px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item.done .item-name { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.qty-pill { background: var(--surface-2); border-radius: 6px; padding: 0 7px; font-size: .85rem; }
.item-by { width: 100%; color: var(--muted); font-size: .76rem; }
.done-section { margin-top: 16px; max-width: 640px; }
.done-section summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 8px 2px; }
.done-section .btn { margin-top: 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.lock { width: 15px; height: 15px; vertical-align: -2px; stroke-width: 2.2; }
.private-note { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; margin: 0 0 4px; }
.sm-lock { color: var(--muted); display: grid; place-items: center; width: 24px; flex: none; }
#sm-add .check-row { margin-top: 8px; font-size: .92rem; }
.store-edit-list { list-style: none; padding: 0; margin: 0 0 12px; }
.store-edit-list li { display: flex; gap: 6px; align-items: center; padding: 6px 0; }
.store-edit-list .sm-name { flex: 1; }
.store-edit-list .sm-color { width: 44px; padding: 4px; flex: none; }

/* ---------- settings ---------- */
.settings { display: grid; gap: 16px; max-width: 640px; }
.settings .card > * + * { margin-top: 12px; }
.notice { background: var(--accent-soft); border-color: transparent; }
.notice p { margin: 0; }
.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.members li:first-child { border-top: 0; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 6, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal {
  position: relative; background: var(--surface); width: 100%; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
@media (min-width: 640px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { max-width: 520px; border-radius: 18px; padding-bottom: 24px; }
  .modal.wide { max-width: 820px; }
}
.modal > h2 { padding-right: 44px; }
.modal-x { position: absolute; top: 12px; right: 12px; background: var(--surface); z-index: 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; margin: 10px 0; }
.pick { font: inherit; text-align: left; color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; }
.pick:hover { border-color: var(--accent); }
.pick small { color: var(--muted); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 14px 0 4px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.inline-label { display: flex; align-items: center; gap: 10px; }
.inline-label select { margin: 0; width: auto; flex: 1; max-width: 260px; }
.atl-groups { display: grid; gap: 12px; margin-top: 14px; }
.modal.wide .atl-groups { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px 10px; margin: 0; }
legend { font-weight: 700; padding: 0 4px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 400; padding: 5px 0; cursor: pointer; }
.check-row input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s, visibility 0s linear .2s; z-index: 60; max-width: calc(100vw - 32px); text-align: center;
  /* Once faded out it's truly gone (not just invisible), and never selectable — an iPhone
     double-tap-and-hold used to find its leftover text ("…updated") and open the copy menu. */
  visibility: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); visibility: visible; transition: opacity .2s, transform .2s, visibility 0s; }
@media (min-width: 800px) { #toast { bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* =================================================================== */
/* v2: profiles, calendar, chores, to-dos, prices, photos               */
/* =================================================================== */
.spacer { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 460px) { .row2, .row3 { grid-template-columns: 1fr; } }
.linklike { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.modal-actions { flex-wrap: wrap; align-items: center; }

/* sub-tabs (Meals: plan/recipes, Lists: shopping/to-dos/prices) */
.subtabs { display: inline-flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 14px; max-width: 100%; overflow-x: auto; }
.subtab { font: inherit; font-weight: 600; font-size: .92rem; color: var(--muted); background: none; border: 0; border-radius: 9px; padding: 8px 14px; min-height: 40px; cursor: pointer; white-space: nowrap; }
.subtab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg-btn { font: inherit; font-weight: 600; font-size: .88rem; color: var(--muted); background: none; border: 0; border-radius: 8px; padding: 6px 12px; min-height: 38px; cursor: pointer; }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* people */
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 800; font-size: 1.05rem; line-height: 1;
}
.avatar.sm { width: 28px; height: 28px; font-size: .8rem; }
.avatar.xs { width: 20px; height: 20px; font-size: .66rem; }
.ev-who .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.person-chip { display: inline-flex; align-items: center; gap: 6px; padding-left: 5px; }
.person-chip.on { background: color-mix(in srgb, var(--c) 18%, var(--surface)); border-color: var(--c); color: var(--text); }
.person-chip:not(.on) { opacity: .6; }
.chips .person-chip:not([data-p]):not(.on) { opacity: 1; }
.chip-n { background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 0 7px; font-size: .78rem; margin-left: 2px; }
.chip.on .chip-n { background: rgba(255,255,255,.25); color: inherit; }
.people-list { list-style: none; padding: 0; margin: 0; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.people-list li:first-child { border-top: 0; }
.pl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: var(--text); }
.swatches input[type=color] { width: 44px; height: 36px; padding: 2px; min-height: 0; }
.cal-pick { list-style: none; padding: 0; margin: 0 0 12px; }
.cal-pick li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--border); }
.cal-pick li:first-child { border-top: 0; }
.cal-pick select { width: auto; min-width: 150px; }

/* calendar */
.cal-layout { display: grid; gap: 16px; align-items: start; }
@media (min-width: 1000px) { .cal-layout { grid-template-columns: minmax(0, 1fr) 320px; } }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-dow { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: center; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.cal-cell {
  font: inherit; color: var(--text); text-align: left; background: none; border: 0; border-top: 1px solid var(--border); border-left: 1px solid var(--border);
  min-height: 92px; padding: 4px; display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; overflow: hidden;
}
.cal-cell:nth-child(7n + 1) { border-left: 0; }
.cal-dow + .cal-cell, .cal-cell:nth-child(-n + 14) { border-top: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other { color: var(--muted); background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: .85rem; font-weight: 700; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.cal-cell.today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-pills { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pill { display: block; font-size: .72rem; font-weight: 600; line-height: 1.25; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--c) 22%, var(--surface)); border-left: 3px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: .7rem; color: var(--muted); font-weight: 600; padding-left: 4px; }
@media (max-width: 699px) {
  .cal-cell { min-height: 54px; align-items: center; padding: 3px 1px; }
  .cal-pills { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .pill { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: var(--c); }
  .pill-t { display: none; }
  .cal-more { display: none; }
}
.cal-day { position: sticky; top: 16px; }
.cal-day-head { display: flex; flex-direction: column; margin-bottom: 10px; }
.cal-day-head h2 { margin: 0; }
.cal-day > .btn { margin-top: 10px; }
.ev-list { display: flex; flex-direction: column; gap: 6px; }
.ev-row {
  font: inherit; color: var(--text); text-align: left; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center;
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 0; border-left: 4px solid var(--c); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.ev-time { grid-column: 1 / -1; font-size: .78rem; font-weight: 600; color: var(--muted); }
.ev-title { grid-column: 1 / 3; font-weight: 600; overflow-wrap: break-word; min-width: 0; }
.ev-who { display: flex; grid-row: 2; grid-column: 3; }
.g-badge { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; font-size: .62rem; font-weight: 800; background: var(--surface-2); color: var(--muted); vertical-align: 1px; }
.up-evs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.up-ev { font: inherit; font-size: .92rem; font-weight: 600; color: var(--text); text-align: left; background: none; border: 0; border-left: 3px solid var(--c); padding: 1px 0 1px 8px; cursor: pointer; overflow-wrap: break-word; }

/* chores */
.chore-board { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.chore-card, .week-chart { border-top: 5px solid var(--c); }
.chore-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chore-head > div { flex: 1; min-width: 0; }
.chore-name { font-weight: 800; font-size: 1.1rem; }
.week-chart .chore-name { flex: 1; }
.points {
  font: inherit; font-weight: 800; display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  background: #fff4d6; color: #8a5a00; border: 1px solid #f0d58a; border-radius: 999px; padding: 4px 10px; min-height: 36px;
}
.points svg { width: 18px; height: 18px; fill: #e0a21a; stroke: #c98a00; }
.points.sm { min-height: 28px; padding: 1px 8px; font-size: .85rem; margin-left: auto; }
.points.sm svg { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .points { background: #3b2f12; color: #f3cf74; border-color: #5c4718; } }
:root[data-theme="dark"] .points { background: #3b2f12; color: #f3cf74; border-color: #5c4718; }
.big-points { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 2.4rem; font-weight: 800; margin: 4px 0 14px; }
.big-points svg { width: 36px; height: 36px; fill: #e0a21a; stroke: #c98a00; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.progress span { display: block; height: 100%; background: var(--c); border-radius: 999px; transition: width .3s; }
.chore-list { list-style: none; margin: 0; padding: 0; }
.chore { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); min-height: 48px; }
.chore:first-child { border-top: 0; }
.chore-title { flex: 1; font-weight: 600; cursor: pointer; padding: 8px 0; overflow-wrap: break-word; min-width: 0; }
.chore.done .chore-title { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.chore.done .check::before, .check.on::before { background: var(--good); border-color: var(--good); }
.check.big::before { width: 28px; height: 28px; border-radius: 9px; }
.chore.old { opacity: .55; }
span.check { display: grid; place-items: center; width: 44px; height: 44px; flex: none; }
span.check::before { content: ""; width: 24px; height: 24px; border: 2px dashed var(--muted); border-radius: 7px; }
.pts { font-size: .75rem; font-weight: 800; color: #8a5a00; background: #fff4d6; border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pts { background: #3b2f12; color: #f3cf74; } }
:root[data-theme="dark"] .pts { background: #3b2f12; color: #f3cf74; }
.week-chart + .week-chart { margin-top: 14px; }
.chart-scroll { overflow-x: auto; }
.chart { border-collapse: collapse; width: 100%; min-width: 520px; }
.chart th, .chart td { border-top: 1px solid var(--border); padding: 2px; text-align: center; }
.chart thead th { border-top: 0; font-size: .78rem; color: var(--muted); font-weight: 700; padding-bottom: 6px; }
.chart thead th small { display: block; font-size: .72rem; font-weight: 500; }
.chart thead th.today { color: var(--accent); }
.chart tbody th { text-align: left; font-weight: 600; padding: 6px 8px 6px 0; }
.chart td.na { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--surface-2) 6px 8px); }
.chart .check { margin: 0 auto; }
.home-person { border-left: 4px solid var(--c); padding-left: 10px; margin-top: 10px; }
.home-person:first-of-type { margin-top: 0; }
.hp-head { display: flex; align-items: center; gap: 8px; }

/* to-dos */
.todo-add { flex-wrap: wrap; }
.todo-add #td-title { flex: 1 1 220px; }
.todo-add select { width: auto; flex: 0 1 160px; min-width: 0; }
.todo-add input[type=date] { width: auto; flex: 0 1 160px; min-width: 0; }
@media (max-width: 560px) {
  .todo-add #td-title { flex-basis: 100%; }
  .todo-add select, .todo-add input[type=date] { flex: 1 1 0; }
}
.due { font-weight: 600; }
.due.today { color: var(--accent); }
.due.overdue { color: var(--danger); }
.todo .item-by { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.items.compact .item { padding: 0 4px; }
.items.compact .check { width: 40px; height: 40px; }
.home .todo .x { display: none; }

/* prices */
.list-total { margin: -4px 0 10px; font-size: .92rem; max-width: 640px; }
.list-total:empty { display: none; }
.price-tag {
  font: inherit; font-size: .85rem; font-weight: 700; color: var(--muted); background: none; border: 1px dashed var(--border);
  border-radius: 8px; min-width: 44px; min-height: 36px; padding: 2px 8px; cursor: pointer; white-space: nowrap; flex: none;
}
.price-tag.set { color: var(--good); border-style: solid; border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.price-tag.known { color: var(--muted); border-style: solid; }
.price-tag small { font-weight: 500; }
.price-book { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.price-card {
  font: inherit; color: var(--text); text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
}
.price-card:hover { border-color: var(--accent); }
.pc-name { font-weight: 700; flex: 1 1 160px; }
.pc-stores { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-store { display: inline-flex; align-items: baseline; gap: 6px; background: var(--surface-2); border-left: 4px solid var(--c); border-radius: 8px; padding: 4px 10px; font-size: .88rem; }
.pc-store.best { background: color-mix(in srgb, var(--good) 16%, var(--surface)); }
.pc-store.best strong::after { content: " ✓"; color: var(--good); }
.pc-sname { color: var(--muted); }
.ph-store { border-left: 4px solid var(--c); padding-left: 12px; margin: 12px 0; }
.ph-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ph-head strong { flex: 1; }
.ph-list { list-style: none; padding: 0; margin: 6px 0 0; font-size: .9rem; }
.ph-list li { display: flex; justify-content: space-between; padding: 3px 0; border-top: 1px solid var(--border); }
.ph-list small.up { color: var(--danger); }
.ph-list small.down { color: var(--good); }

/* press-and-hold drag to reorder (js/dragsort.js) and tap-to-edit text (App.inlineEdit) */
[data-drag-id] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.dragging {
  position: relative; z-index: 5; background: var(--surface) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.28), 0 0 0 2px var(--accent) !important; border-radius: 12px;
  transform: scale(1.02); transition: transform .12s;
}
body.is-dragging { cursor: grabbing; }
body.is-dragging, body.is-dragging * { -webkit-user-select: none; user-select: none; }
@media (prefers-reduced-motion: reduce) { .dragging { transform: none; transition: none; } }
input.inline-edit {
  font: inherit; font-weight: 600; min-height: 36px; padding: 4px 8px; margin: -4px 0; width: 100%;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--surface);
  -webkit-user-select: text; user-select: text;
}

/* grocery sections on shopping lists */
.aisle { max-width: 640px; }
.aisle + .aisle { margin-top: 12px; }
.aisle-head {
  font: inherit; color: var(--text); background: none; border: 0; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 8px; padding: 6px 2px; min-height: 40px; text-align: left;
}
.aisle-name { font-weight: 800; font-size: .95rem; }
.aisle-caret { color: var(--muted); width: 14px; }
.aisle-head .count { background: var(--surface-2); border-radius: 999px; min-width: 24px; padding: 1px 8px; font-size: .78rem; font-weight: 700; text-align: center; }

/* recipe photos */
.photo-field { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.photo-preview { width: 120px; height: 90px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ===== lists.js: tap item / to-do text to fix it; hold a shopping item to reorder ===== */
.item-main { cursor: default; }
.item-main[data-item], #td-list .item-main { cursor: text; }
[data-edit-name], [data-edit-qty], [data-edit-todo-title] { cursor: text; border-radius: 6px; }
[data-edit-name]:focus-visible, [data-edit-qty]:focus-visible, [data-edit-todo-title]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) {
  .item:not(.done) [data-edit-name]:hover, .item:not(.done) [data-edit-todo-title]:hover { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
  [data-edit-qty]:hover { background: var(--accent-soft); }
}
.item-name.is-editing { flex: 1 1 100%; min-width: 0; }
.qty-pill.is-editing { flex: 0 1 8em; min-width: 0; padding: 0; background: none; }
.item-main input.inline-edit { font-size: max(16px, 1em); color: var(--text); box-sizing: border-box; max-width: 100%; } /* 16px stops iPhone zooming in */
.qty-pill.is-editing input.inline-edit { font-weight: 500; }
.items.drag-group.drag-active { overflow: visible; } /* don't clip the lifted row's shadow */

/* ---------- Settings → Appearance (colors come from js/theme.js) ---------- */
.ap-mode { display: flex; max-width: 360px; }
.ap-mode .seg-btn { flex: 1; min-height: 44px; font-size: .95rem; }
.ap-mode .seg-btn.on { color: var(--accent); }
.appearance .ap-hint { margin-top: 6px; }
.ap-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.ap-swatch {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer;
  min-width: 44px; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.ap-dot { width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.ap-swatch.on .ap-dot { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.ap-swatch.on { color: var(--text); }
.ap-swatch:focus-visible { outline-offset: 0; border-radius: 10px; }
.ap-name { display: none; font-size: .75rem; font-weight: 600; line-height: 1.1; }
@media (min-width: 600px) {
  .ap-swatches { gap: 4px; }
  .ap-swatch { width: 72px; padding: 6px 0; }
  .ap-name { display: block; }
}
.ap-custom { margin-top: 12px; gap: 12px; }
.ap-color { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.ap-color input[type=color] { width: 56px; height: 44px; min-height: 44px; padding: 3px; cursor: pointer; }

/* ===== No zoom on text boxes =====
   iPhones zoom the whole page in when a text box with text smaller than 16px is tapped.
   Keep every text box at 16px or more (inputs inside smaller labels inherit .9rem otherwise). */
input, select, textarea { font-size: max(1rem, 1em); }
