/* ---------- Theme tokens ---------- */
:root {
  --bg: #f3f0e9;
  --surface: #ffffff;
  --surface-2: #f7f5f0;
  --surface-3: #eeeae1;
  --text: #1e2227;
  --muted: #6a6f77;
  --border: #e2ddd2;
  --border-soft: #efebe3;
  --accent: #3b6fd8;
  --accent-soft: rgba(59, 111, 216, .12);
  --accent-ink: #fff;
  --danger: #d64545;
  --ok: #2e9e5b;
  --ok-soft: rgba(46, 158, 91, .14);
  --warn: #d99211;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 20px rgba(20, 20, 30, .06);
  --radius: 16px;
  --radius-sm: 10px;
  --slot-h: 30px;
  --gutter: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --surface: #1b1e24; --surface-2: #22262d; --surface-3: #2a2f37;
    --text: #e7e9ec; --muted: #9aa1aa; --border: #30353d; --border-soft: #262a31;
    --accent: #6b95ee; --accent-soft: rgba(107, 149, 238, .16); --ok-soft: rgba(46, 158, 91, .22);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --surface: #1b1e24; --surface-2: #22262d; --surface-3: #2a2f37;
  --text: #e7e9ec; --muted: #9aa1aa; --border: #30353d; --border-soft: #262a31;
  --accent: #6b95ee; --accent-soft: rgba(107, 149, 238, .16); --ok-soft: rgba(46, 158, 91, .22);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base layout ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "nav main";
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }

.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 700; }
.brand-icon { font-size: 1.6rem; }
.clock { display: flex; align-items: baseline; gap: 14px; }
#clock-time { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
#clock-date { font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.top-actions { justify-self: end; display: flex; gap: 8px; }

.sidenav {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.nav-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 4px;
  border: 0; border-radius: 14px;
  background: transparent;
  cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--muted);
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.on { background: var(--accent-soft); color: var(--accent); }
.nav-icon { font-size: 1.8rem; line-height: 1.1; }
.nav-badge {
  position: absolute; top: 6px; right: 10px;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--danger); color: #fff;
  font-size: .75rem; display: grid; place-items: center;
}

.main { grid-area: main; overflow: auto; padding: 18px 20px 28px; min-width: 0; }
.main.view-calendar { overflow: hidden; display: flex; flex-direction: column; padding-bottom: 16px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.icon { width: 44px; padding: 0; font-size: 1.5rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.btn:focus-visible, .nav-btn:focus-visible, .chore:focus-visible, .slot:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 9px;
  font-weight: 600; cursor: pointer; color: var(--muted); min-height: 38px;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tb-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-title { font-size: 1.45rem; margin: 0 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
section.card { padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 1.2rem; }

.empty { padding: 28px; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius); }

.inline-select { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); }
.inline-select select, .field input, .field select, .field textarea, .quick-add input, .search {
  min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
}
.field textarea { min-height: 90px; resize: vertical; }

/* ---------- Member chips ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px 6px 6px; min-height: 40px;
  border: 2px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.chip .av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--c, var(--surface-3)); font-size: 1rem; }
.chip.on { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); }
.chip.everyone { padding-left: 14px; }
.who {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px 2px 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 16%, transparent); font-size: .85rem; font-weight: 600;
}

/* ---------- Calendar ---------- */
.cal-wrap { display: flex; gap: 16px; flex: 1; min-height: 0; }
.calendar { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.tg-scroll { flex: 1; overflow: auto; position: relative; }
.tg-row { display: grid; grid-template-columns: var(--gutter) repeat(var(--cols), minmax(0, 1fr)); }
.tg-sticky { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--border); }
.tg-head-cell {
  padding: 8px 4px; text-align: center; border-left: 1px solid var(--border-soft);
  cursor: pointer; background: none; border-top: 0; border-right: 0; border-bottom: 0;
}
.tg-head-cell:hover { background: var(--surface-2); }
.tg-head-cell .dow { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.tg-head-cell .dnum { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.tg-head-cell.today .dnum { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.tg-head-cell.member { cursor: default; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.tg-head-cell.member .av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--c); font-size: 1.2rem; }
.tg-allday { min-height: 34px; border-top: 1px solid var(--border-soft); }
.tg-allday .gut { font-size: .72rem; color: var(--muted); padding: 8px 6px; text-align: right; }
.tg-allday .cell { border-left: 1px solid var(--border-soft); padding: 3px; display: flex; flex-direction: column; gap: 3px; }
.ad-chip {
  background: var(--ev-c); color: #fff; border-radius: 7px; padding: 3px 8px;
  font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-gutter { position: relative; }
.tg-hour { height: calc(var(--slot-h) * 2); position: relative; }
.tg-hour span { position: absolute; right: 8px; top: -8px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.tg-hour:first-child span { top: 3px; }
.tg-col { position: relative; border-left: 1px solid var(--border-soft); }
.slot { height: var(--slot-h); border-top: 1px solid var(--border); cursor: pointer; }
.slot.half { border-top: 1px dashed var(--border-soft); }
.slot:hover { background: var(--accent-soft); }
.slot:hover::after { content: "+"; display: block; text-align: center; color: var(--accent); font-weight: 700; line-height: var(--slot-h); }
.tg-col.today-col { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.ev {
  position: absolute; z-index: 2;
  background: var(--ev-c); color: #fff;
  border-radius: 8px; padding: 3px 7px;
  font-size: .82rem; line-height: 1.25;
  overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  border: 1px solid color-mix(in srgb, var(--ev-c) 70%, #000);
}
.ev:hover { filter: brightness(1.07); z-index: 3; }
.ev-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-time { opacity: .92; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.short { display: flex; gap: 6px; align-items: center; padding-top: 1px; padding-bottom: 1px; }
.ev.short .ev-title { flex: 0 1 auto; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.month { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.month-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.month-head div { padding: 8px; text-align: center; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(90px, 1fr); overflow: auto; }
.mcell { border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); padding: 4px; cursor: pointer; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.mcell:hover { background: var(--surface-2); }
.mcell.out { background: var(--surface-2); }
.mcell.out .mnum { color: var(--muted); opacity: .6; }
.mnum { font-weight: 700; font-size: .95rem; padding: 2px 4px; align-self: flex-start; }
.mcell.today .mnum { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 2px 9px; }
.mchip { font-size: .78rem; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--ev-c) 18%, transparent); border-left: 4px solid var(--ev-c); font-weight: 600; }
.mchip.allday { background: var(--ev-c); color: #fff; }
.mmore { font-size: .75rem; color: var(--muted); font-weight: 700; padding-left: 4px; }

/* Today panel */
.today-panel { width: 300px; flex-shrink: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.tp-card { padding: 14px 16px; }
.tp-card h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.tp-card h4 button { border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; font-size: .8rem; letter-spacing: 0; text-transform: none; }
.tp-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.tp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ev-c); flex-shrink: 0; }
.tp-time { color: var(--muted); font-size: .85rem; min-width: 64px; font-variant-numeric: tabular-nums; }
.tp-meal { padding: 4px 0; font-weight: 600; }
.tp-meal .muted { display: inline-block; min-width: 82px; font-weight: 500; font-size: .85rem; }
.mini-progress { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.mini-progress div { height: 100%; background: var(--c); border-radius: 5px; }
.tp-big { font-size: 1.6rem; font-weight: 800; }

/* ---------- Chores ---------- */
.kid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kid-card {
  background: var(--surface); border-radius: 22px; padding: 18px;
  border: 3px solid color-mix(in srgb, var(--kc) 45%, transparent);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.kid-card.all-done { background: color-mix(in srgb, var(--kc) 10%, var(--surface)); }
.kid-head { display: flex; align-items: center; gap: 12px; }
.kid-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--kc); display: grid; place-items: center; font-size: 2.2rem; flex-shrink: 0; }
.kid-id { flex: 1; min-width: 0; }
.kid-name { font-size: 1.5rem; font-weight: 800; }
.kid-level { color: var(--muted); font-weight: 600; font-size: .9rem; }
.kid-stars { font-size: 1.4rem; font-weight: 800; background: #fff3c4; color: #7a5600; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.progress { height: 16px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--kc), color-mix(in srgb, var(--kc) 60%, #ffd84d)); border-radius: 8px; transition: width .4s ease; }
.progress-label { font-weight: 700; color: var(--muted); font-size: .9rem; }
.chore-list { display: flex; flex-direction: column; gap: 8px; }
.chore {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 60px;
  border: 2px solid var(--border); border-radius: 16px;
  background: var(--surface-2); cursor: pointer; text-align: left;
  transition: transform .1s ease, background .2s ease;
}
.chore:hover { border-color: var(--kc); }
.chore:active { transform: scale(.98); }
.chore:disabled { cursor: not-allowed; opacity: .6; }
.chore-emoji { font-size: 1.8rem; }
.chore-title { flex: 1; font-weight: 700; font-size: 1.05rem; }
.chore-pts { font-weight: 800; color: #b07d00; background: #fff3c4; padding: 2px 10px; border-radius: 999px; font-size: .9rem; }
.chore-check { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); display: grid; place-items: center; font-weight: 900; font-size: 1.2rem; flex-shrink: 0; }
.chore.done { background: var(--ok-soft); border-color: var(--ok); }
.chore.done .chore-title { text-decoration: line-through; opacity: .7; }
.chore.done .chore-check { background: var(--ok); border-color: var(--ok); color: #fff; animation: pop .35s ease; }
.all-done-banner { text-align: center; font-weight: 800; font-size: 1.2rem; padding: 10px; border-radius: 14px; background: var(--ok); color: #fff; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }

.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.reward {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px; border: 2px solid var(--border); border-radius: 18px;
  background: var(--surface-2); cursor: pointer; font-weight: 700; text-align: center;
}
.reward:hover { border-color: var(--warn); }
.reward-emoji { font-size: 2.4rem; }
.reward-cost { color: #b07d00; background: #fff3c4; padding: 2px 10px; border-radius: 999px; font-size: .9rem; }
.feed-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.feed-row:last-child { border-bottom: 0; }
.feed-row .amt { margin-left: auto; font-weight: 800; }
.amt.pos { color: var(--ok); }
.amt.neg { color: var(--danger); }

/* ---------- Generic lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-soft); }
.list-row:last-child { border-bottom: 0; }
.lr-emoji { font-size: 1.7rem; width: 40px; text-align: center; }
.lr-main { flex: 1; min-width: 0; }
.lr-title { font-weight: 700; }
.lr-sub { color: var(--muted); font-size: .88rem; }
.swatch-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--c); display: inline-block; vertical-align: middle; }

.quick-add { display: flex; gap: 8px; margin-bottom: 16px; }
.quick-add input { flex: 1; font-size: 1.05rem; min-height: 52px; }
.quick-add .btn { min-height: 52px; }

/* Honey-do */
.hd-item { display: flex; align-items: flex-start; gap: 14px; padding: 14px; border-bottom: 1px solid var(--border-soft); }
.hd-item:last-child { border-bottom: 0; }
.check-btn {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  border: 3px solid var(--border); background: var(--surface); cursor: pointer;
  font-weight: 900; font-size: 1.2rem; display: grid; place-items: center;
}
.check-btn:hover { border-color: var(--ok); }
.done .check-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
.hd-main { flex: 1; min-width: 0; cursor: pointer; }
.hd-title { font-weight: 700; font-size: 1.1rem; }
.done .hd-title { text-decoration: line-through; color: var(--muted); }
.hd-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; align-items: center; font-size: .88rem; }
.hd-notes { color: var(--muted); font-size: .9rem; margin-top: 4px; white-space: pre-wrap; }
.badge { padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .78rem; background: var(--surface-3); }
.badge.high { background: #fde2e2; color: #a12626; }
.badge.medium { background: #fff1cc; color: #7a5600; }
.badge.low { background: #dff3e7; color: #1d6b3d; }
.badge.overdue { background: var(--danger); color: #fff; }
.badge.src { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Grocery */
.g-cat { margin-bottom: 14px; }
.g-cat h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 6px 4px; }
.g-item { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--border-soft); }
.g-item:last-child { border-bottom: 0; }
.g-name { flex: 1; font-weight: 600; font-size: 1.08rem; cursor: pointer; min-width: 0; }
.g-qty { color: var(--accent); font-weight: 800; margin-right: 4px; }
.g-item.done .g-name { text-decoration: line-through; color: var(--muted); }
.g-columns { columns: 2 340px; column-gap: 18px; }
.g-columns .g-cat { break-inside: avoid; }

/* Meals */
.meal-grid { display: grid; grid-template-columns: 150px repeat(var(--slots), minmax(0, 1fr)); gap: 8px; }
.meal-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 4px 8px; }
.meal-day { padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.meal-day .dow { font-weight: 800; }
.meal-day .dt { color: var(--muted); font-size: .85rem; }
.meal-day.today { border-color: var(--accent); background: var(--accent-soft); }
.meal-cell {
  min-height: 64px; padding: 10px; border-radius: 12px; text-align: left;
  border: 2px dashed var(--border); background: transparent; cursor: pointer; color: var(--muted); font-weight: 600;
}
.meal-cell:hover { border-color: var(--accent); color: var(--accent); }
.meal-cell.filled { border-style: solid; background: var(--surface); color: var(--text); }
.meal-cell .me { font-size: 1.4rem; margin-right: 6px; vertical-align: middle; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.recipe-card { padding: 16px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); }
.recipe-card:hover { border-color: var(--accent); }
.recipe-card .re { font-size: 2.6rem; }
.recipe-card .rn { font-weight: 800; font-size: 1.1rem; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.recipe-pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.recipe-view h4 { margin: 14px 0 6px; }
.recipe-view ul { margin: 0; padding-left: 22px; }
.recipe-view li { padding: 2px 0; }
.recipe-view .steps { white-space: pre-wrap; }

/* ---------- Modal & forms ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 16, .5);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease;
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  animation: rise .18s ease;
}
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.modal header h3 { font-size: 1.3rem; }
.modal-body { padding: 8px 20px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal footer { display: flex; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.modal footer .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field > span { font-weight: 700; font-size: .88rem; color: var(--muted); }
.field small { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; }
.hint { background: var(--accent-soft); color: var(--text); padding: 8px 12px; border-radius: 10px; font-size: .9rem; }

.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; min-height: 42px;
  border: 2px solid var(--border); border-radius: 999px;
  cursor: pointer; font-weight: 600; background: var(--surface);
}
.pick input:checked + span { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--surface)); }
.pick input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.recipe-pick-list .pick span { width: 100%; border-radius: 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch i { display: block; width: 36px; height: 36px; border-radius: 50%; background: var(--sw); border: 3px solid transparent; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch input:checked + i { border-color: var(--text); }
.swatch.auto i { width: auto; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--surface-3); display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: .85rem; box-shadow: none; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.emoji-btn { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 1.3rem; cursor: pointer; }
.emoji-btn:hover { border-color: var(--accent); }
.emoji-input { width: 80px; text-align: center; font-size: 1.6rem; }

.pin-input { font-size: 2rem; text-align: center; letter-spacing: .4em; }
.who-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.who-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px; border: 2px solid var(--border); border-radius: 16px; background: var(--surface-2); cursor: pointer; font-weight: 700; }
.who-btn:hover:not(:disabled) { border-color: var(--c); }
.who-btn:disabled { opacity: .45; cursor: not-allowed; }
.who-btn .big { font-size: 2.2rem; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

/* ---------- Sign-in gate & account ---------- */
#gate {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg); overflow-y: auto;
  display: grid; place-items: center; padding: 24px 16px;
}
#gate[hidden] { display: none; }
.gate-card { width: min(460px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.gate-card.wide { width: min(520px, 100%); align-items: center; text-align: center; }
.gate-card form { display: flex; flex-direction: column; gap: 12px; }
.gate-brand { font-size: 1.6rem; font-weight: 800; }
.gate-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.spinner { width: 40px; height: 40px; margin: 8px auto; border-radius: 50%; border: 4px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.invite-code {
  font-size: 2rem; font-weight: 800; letter-spacing: .15em; text-align: center;
  padding: 14px; border-radius: 14px; background: var(--surface-2); border: 2px dashed var(--border);
}
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); }
.list-row select { min-height: 36px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.sync-dot[data-state="saving"] { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.sync-dot[data-state="offline"] { background: var(--muted); }
.sync-dot[data-state="error"] { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Effects ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti {
  position: absolute; width: 10px; height: 14px; border-radius: 2px;
  animation: burst 1.3s cubic-bezier(.2, .7, .4, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 260px)) rotate(var(--r)); opacity: 0; }
}
.star-pop { position: absolute; font-size: 1.8rem; font-weight: 900; color: #e0a000; animation: floatup 1.1s ease forwards; text-shadow: 0 2px 6px rgba(0,0,0,.2); }
@keyframes floatup { to { transform: translateY(-80px) scale(1.3); opacity: 0; } }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 12px;
  font-weight: 600; z-index: 120; transition: transform .25s ease; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1150px) { .today-panel { display: none; } }
@media (max-width: 760px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "top" "main" "nav"; }
  .sidenav { flex-direction: row; justify-content: space-around; padding: 4px; border-right: 0; border-top: 1px solid var(--border); }
  .nav-btn { flex: 1; padding: 6px 2px; font-size: .7rem; }
  .nav-icon { font-size: 1.4rem; }
  .topbar { grid-template-columns: 1fr auto; padding: 8px 16px; }
  .clock { flex-direction: column; gap: 0; align-items: flex-end; }
  #clock-time { font-size: 1.4rem; }
  #clock-date { font-size: .8rem; }
  .top-actions { display: none; }
  .main { padding: 12px 16px 20px; }
  .tb-title { font-size: 1.15rem; }
  :root { --gutter: 48px; }
  .meal-grid { grid-template-columns: 1fr; }
  .meal-head { display: none; }
}
