@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-vf.woff2") format("woff2-variations"), url("/fonts/inter-vf.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #fdf4ee;
  --card: #ffffff;
  --ink: #355070;
  --muted: #6d597a;
  --border: #eae0e6;
  --accent: #e56b6f;
  --accent-ink: #ffffff;
  --accent-soft: #f9dadb;
  --ok: #4f9d69;
  --shadow-sm: 0 1px 2px rgba(33, 28, 21, 0.06), 0 1px 1px rgba(33, 28, 21, 0.04);
  --shadow-md: 0 8px 24px rgba(33, 28, 21, 0.10), 0 2px 6px rgba(33, 28, 21, 0.06);
  --shadow-lg: 0 -12px 40px rgba(33, 28, 21, 0.18);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --font-display: "Fraunces", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/*
 * The kiosk is always-on in a lit room and stays light. A phone gets opened in bed, so it
 * follows the device. Only the tokens change; every rule above and below is shared.
 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17141a;
    --card: #221e28;
    --ink: #ece7ee;
    --muted: #a79fb0;
    --border: #332d3b;
    --accent: #f08a8d;
    --accent-ink: #2a1214;
    --accent-soft: #3b2429;
    --ok: #5fae7a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 -12px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
  .toast { background: #38323f; }
  .pill-count { background: var(--accent-soft); color: var(--accent); }
  .offline-banner { background: #3d3320; color: #e8c98a; }
  .toggle .knob { background: #ddd6e2; }
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
body.sheet-locked { overflow: hidden; }

.i { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex: none; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- App bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px;
  /* Solid fallback first: color-mix() needs Safari 16.2 / Chrome 111, which rules out
     pre-2017 iPads and most Fire tablets' Silk browser. Without this the whole
     declaration is dropped and the bar renders transparent over scrolling content. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 12px;
}
.appbar.scrolled { border-bottom-color: var(--border); }
.appbar h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  margin: 0;
  letter-spacing: -0.01em;
}
.appbar-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.appbar-action {
  border: none;
  background: var(--card);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 19px;
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
}

.appbar-me {
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}
.appbar-me-empty {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--muted);
  border: 1.5px dashed var(--border);
  box-shadow: none;
}
.appbar-me-empty .i { width: 15px; height: 15px; }

.offline-banner {
  background: #fbe9c9;
  color: #7a5a12;
  font-size: 13px;
  text-align: center;
  padding: 7px 12px;
}

/* ---------- View ---------- */

.view { padding: 4px 16px 24px; }
.view-section { margin-top: 22px; }
.view-section:first-child { margin-top: 8px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 2px 8px;
}
.section-head h2 {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0;
}
.section-head button {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px;
}

.card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.row:last-child { border-bottom: none; }
.row:active { background: #faf6f4; }
.row-title { font-size: 16px; font-weight: 550; line-height: 1.3; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.done-text { text-decoration: line-through; opacity: 0.5; }

.checkbox {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: transparent;
  flex: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.checkbox.checked { background: var(--ok); border-color: var(--ok); color: #fff; }
/* the tap target is bigger than the ink */
.checkbox-hit { padding: 8px; margin: -8px; display: flex; flex: none; }

/* ---------- Swipe actions (Tasks & Groceries rows) ---------- */
/* See components/swipe.js — wraps a row's existing children into .swipe-content at
   mount time and slides that on top of one or two color-coded action layers beneath. */

.swipe-row { position: relative; overflow: hidden; padding: 0; }
.swipe-content {
  /* Above the action layers for hit-testing, not just painting. The bg layers are
     position:absolute, and positioned boxes hit-test over static siblings regardless of
     DOM order - so without this, an invisible swipe-bg sat on top of every row and ate
     the checkbox tap, which then bubbled to the row and opened the editor instead.
     Found via the ?diag=1 HUD on a real phone: path "i > swipe-bg > row". */
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  min-height: 56px;
  background: var(--card);
  touch-action: pan-y;
}
.swipe-row:not(:last-child) .swipe-content { border-bottom: 1px solid var(--border); }

.swipe-bg {
  /* Belt to the z-index braces: these layers are revealed by a gesture and act on
     commit, never on click, so they have no business receiving pointer events at all. */
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.swipe-bg .i { width: 20px; height: 20px; flex-shrink: 0; }
.swipe-bg-left { justify-content: flex-end; background: var(--accent); }
.swipe-bg-right { justify-content: flex-start; background: var(--ok); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 650;
  flex: none;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.time-col {
  width: 62px;
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}
.time-col .end { display: block; font-weight: 500; opacity: 0.75; }

.stripe { width: 4px; align-self: stretch; border-radius: 2px; flex: none; background: var(--border); }

.empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
}
.empty .i { font-size: 34px; display: block; margin: 0 auto 12px; opacity: 0.45; }
.empty-line { font-size: 14px; line-height: 1.5; }

.pill-count {
  background: var(--accent-soft);
  color: #a8474b;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 650;
}

/* A feature this household's plan doesn't include. Same soft-accent pill language as
   .pill-count, but its own class: a count and a plan tier aren't the same kind of fact,
   even though they look alike. */
.plan-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  background: var(--accent-soft);
  color: #a8474b;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
/* The [hidden] attribute and an explicit `display` on the same element conflict at equal
   CSS specificity - whichever rule comes later in the stylesheet wins, so without this,
   .plan-badge's own display:inline-block silently overrides `hidden` and the badge never
   actually hides. */
.plan-badge[hidden] { display: none; }
.row.locked .nav-icon { opacity: 0.4; }
.row.locked .row-sub { color: var(--muted); }
.row.locked .chev { opacity: 0.3; }

/* Paste-a-link, under the photo buttons on the recipe tab. Presented as the quieter
   sibling of the photo actions rather than a competing primary path: most people reach for
   the camera, and the ones who have a link in hand are looking for it. */
.link-drop { margin-top: 20px; padding: 0 4px; }
.link-drop-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.link-row { display: flex; gap: 8px; }
.link-row input {
  flex: 1;
  min-width: 0;          /* without this a long placeholder pushes the button off-screen */
  padding: 12px;
  font-size: 16px;       /* under 16px iOS Safari zooms the page on focus */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
}
.link-row .photo-btn { flex: 0 0 auto; }
.link-drop-note { margin-top: 8px; font-size: 13px; }

/* Explanatory prose that belongs to the card above it but is too long to be a row-sub.
   Sits outside the card so the card stays a list of things you can tap. */
.card-note {
  margin: 8px 4px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--card); /* fallback — see .appbar */
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
}
.tab .i { font-size: 22px; position: relative; z-index: 1; transition: transform 0.25s var(--ease); }
.tab span { position: relative; z-index: 1; }
.tab { position: relative; transition: color 0.2s var(--ease); }
/* The you-are-here pill. Colour alone was the whole active state before, which is easy
   to miss and invisible to anyone who can't tell coral from grey. A shape that arrives
   is legible to everyone, and its spring-in doubles as the tab-change animation. */
.tab::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 46px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  opacity: 0;
  transform: translateX(-50%) scale(0.55);
  transition: opacity 0.2s var(--ease), transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tab.active { color: var(--accent); }
.tab.active::before { opacity: 1; transform: translateX(-50%) scale(1); }
.tab.active .i { transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) {
  .tab::before, .tab .i { transition: none; }
}

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
}
.fab:active { transform: scale(0.94); }

/* ---------- Quick add ---------- */

.quickadd {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 25;
  background: var(--card); /* fallback — see .appbar */
  background: color-mix(in srgb, var(--card) 95%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}
.quickadd-row { display: flex; gap: 8px; align-items: center; }
.quickadd input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* below 16px iOS Safari zooms the page on focus */
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}
.quickadd input:focus { outline: none; border-color: var(--accent); }
.quickadd-send {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
  display: grid;
  place-items: center;
}
.quickadd-send:disabled { opacity: 0.4; }
.quickadd-types { display: flex; gap: 6px; margin-bottom: 8px; }
.quickadd-types button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
}
.quickadd-types button.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
body.has-quickadd { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 104px); }
.quickadd-scan {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-size: 18px;
  display: grid;
  place-items: center;
}

.lightbox-recrop {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #221c26;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 650;
  padding: 12px 20px;
  box-shadow: var(--shadow-md);
}
.lightbox-recrop .i { width: 17px; height: 17px; }

/* ---------- Help ---------- */

.help-input {
  width: 100%;
  font-size: 16px; /* below 16px iOS Safari zooms the page on focus */
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
}
.help-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Google: choosing calendars to import ---------- */

.gcal-row { gap: 12px; }
.gcal-row .link-btn { flex: none; padding: 8px 2px; }
.gcal-who-list { display: grid; gap: 8px; margin-bottom: 8px; }
.gcal-who {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 13px 15px;
  margin-bottom: 8px;
}
.gcal-who .i { width: 18px; height: 18px; color: var(--accent); }
.gcal-who-mixed { border-color: var(--accent); }

/* ---------- Photo submission: what am I scanning ---------- */

.scan-modes { display: grid; gap: 10px; margin-bottom: 18px; }
.scan-mode {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon title" "icon sub";
  gap: 2px 12px;
  align-items: start;
  text-align: left;
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.scan-mode.on { border-color: var(--accent); background: var(--accent-soft); }
.scan-mode .i { grid-area: icon; width: 22px; height: 22px; color: var(--accent); margin-top: 2px; }
.scan-mode-t { grid-area: title; font-size: 16px; font-weight: 650; }
.scan-mode-s { grid-area: sub; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.scan-mode.on .scan-mode-s { color: var(--ink); opacity: 0.75; }

/* ---------- Photo submission: scan review ---------- */

.scan-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 12px;
  font-size: 13.5px;
}
.scan-card { padding: 14px; margin-bottom: 12px; transition: opacity 0.15s var(--ease); }
.scan-card-excluded { opacity: 0.5; }
.scan-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.scan-check {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
}
.scan-check.on { background: var(--accent); border-color: var(--accent); }
.scan-check .i { width: 15px; height: 15px; }
.scan-field-title {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 650;
  border: none;
  background: none;
  color: var(--ink);
  font-family: inherit;
  padding: 4px 0;
}
.scan-field-title:focus { outline: none; }
.scan-flag {
  font-size: 12.5px;
  font-weight: 600;
  color: #a8474b;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
}
/* A duplicate is information, not a problem, so it reads calmer than the accent-coloured
   low-confidence flag it replaces. */
.scan-flag.scan-dupe { background: var(--bg); color: var(--muted); font-weight: 600; }
.scan-card-row { display: flex; gap: 8px; margin-bottom: 8px; }
.scan-field {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}
.scan-field:focus { outline: none; border-color: var(--accent); }
.scan-field-flag { border-color: #a8474b; }
textarea.scan-field { width: 100%; min-height: 44px; resize: vertical; margin-bottom: 8px; }
.scan-allday {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 4px;
}
.scan-card-members { margin-top: 4px; }
.scan-review-actions { display: flex; gap: 10px; margin: 6px 4px 24px; }
.scan-discard {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  padding: 13px;
  border-radius: 0.75rem;
}
.scan-review-actions .login-btn { flex: 1; }
.scan-ing { gap: 12px; }
.scan-ing-off .row-title, .scan-ing-off .row-sub { opacity: 0.55; }
.scan-ing-flag {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #a8474b;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---------- Segmented control ---------- */

.segmented {
  display: flex;
  background: var(--border); /* fallback — see .appbar */
  background: color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 999px;
}
.segmented button.selected {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- Agenda ---------- */

.agenda-day { margin-top: 20px; }
.agenda-day:first-child { margin-top: 6px; }
.agenda-date {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 2px 8px;
}
.agenda-date strong { font-size: 15px; font-weight: 650; }
.agenda-date.is-today strong { color: var(--accent); }
.agenda-date span { font-size: 13px; color: var(--muted); }

/* ---------- Month grid ---------- */

.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
}
.month-head h2 { font-family: var(--font-display); font-size: 19px; margin: 0; font-weight: 600; }
.month-nav {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 17px;
  display: grid;
  place-items: center;
}
.month-grid {
  display: grid;
  /* minmax(0, 1fr), not 1fr. A bare 1fr is minmax(auto, 1fr), and that auto floor is the
     cell's min-content width - which aspect-ratio:1 below inflates to match the cell's
     content HEIGHT. The columns then refuse to shrink past ~80px and the last days of
     every week hang off the side of the phone. */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}
.month-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  padding-bottom: 4px;
}
.month-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 550;
  box-shadow: var(--shadow-sm);
}
.month-cell.empty { background: none; box-shadow: none; }
.month-cell.today { background: var(--accent); color: var(--accent-ink); }
.month-cell.selected { outline: 2px solid var(--ink); }
.month-dots { display: flex; gap: 3px; height: 6px; align-items: center; }
.month-dots .dot { width: 5px; height: 5px; }

/* ---------- Sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(33, 28, 21, 0);
  transition: background 0.22s var(--ease);
  display: flex;
  align-items: flex-end;
}
.sheet-backdrop.sheet-open { background: rgba(33, 28, 21, 0.34); }
.sheet {
  width: 100%;
  max-height: 92dvh;
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.28s var(--ease);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet-open .sheet { transform: translateY(0); }
.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 8px auto 0;
  flex: none;
}
.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 14px 12px;
  flex: none;
}
.sheet-head h2 { font-size: 16px; font-weight: 650; margin: 0; text-align: center; white-space: nowrap; }
.sheet-cancel, .sheet-save {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  padding: 6px 2px;
  color: var(--muted);
}
.sheet-cancel { justify-self: start; }
.sheet-save { justify-self: end; color: var(--accent); font-weight: 650; }
.sheet-save:disabled { opacity: 0.5; }
.sheet-body {
  overflow-y: auto;
  padding: 0 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.field-half { width: calc(50% - 7px); }
.field-inline { flex-direction: row; align-items: center; justify-content: space-between; }
.field-label { font-size: 12.5px; font-weight: 650; color: var(--muted); letter-spacing: 0.01em; }
.field input, .field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 46px;
}
.field textarea { resize: none; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input.invalid, .field textarea.invalid { border-color: var(--accent); background: var(--accent-soft); }

.member-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 14px;
  border-radius: 999px;
}
.member-chip.selected { border-color: var(--ink); }
.member-chip[data-value=""].selected { background: var(--ink); color: #fff; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.swatch.selected { border-color: var(--ink); }

.toggle {
  width: 50px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: var(--border);
  padding: 3px;
  display: flex;
  transition: background 0.18s var(--ease);
}
.toggle .knob {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease);
}
.toggle.on { background: var(--ok); }
.toggle.on .knob { transform: translateX(20px); }

.sheet-delete, .sheet-action {
  width: 100%;
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 14px;
  margin-top: 4px;
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #3c3238;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.toast-in { opacity: 1; transform: none; }
.toast-msg { flex: 1; }
.toast-action {
  border: none;
  background: none;
  color: #ffb3b6;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 2px;
}

/* ---------- Pull to refresh ---------- */

.ptr {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  left: 50%;
  z-index: 40;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  font-size: 16px;
  opacity: 0;
  transform: translateY(-14px);
  pointer-events: none;
}
.ptr.spinning .i { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---------- Lists ---------- */

.list-emoji { font-size: 24px; line-height: 1; flex: none; width: 30px; text-align: center; }

.back-link {
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 2px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cat-group { margin-top: 14px; }
.cat-group:first-child { margin-top: 4px; }

.cat-head {
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 4px 6px;
}

.suggest-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.suggest-row::-webkit-scrollbar { display: none; }
.suggest-row:empty { display: none; }

.suggest {
  flex: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.suggest:active { background: var(--accent-soft); border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  padding: 8px 13px;
  border-radius: 999px;
}
.chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}

.chip-custom {
  width: 100%;
  margin-top: 8px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}
.chip-custom:focus { outline: none; border-style: solid; border-color: var(--accent); }
.chip-custom.has-value { border-style: solid; border-color: var(--ink); }

/* ---------- Meals ---------- */

.meal-tag {
  width: 74px;
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.meal-slot { min-height: 50px; padding-top: 11px; padding-bottom: 11px; }
.meal-blank { color: var(--muted); font-weight: 500; opacity: 0.75; }

/* ---------- Crop (landscape, required before any photo upload completes) ---------- */

.crop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
  color: #fff;
}

.crop-header {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
}
.crop-title { font-size: 15px; font-weight: 650; text-align: center; white-space: nowrap; }
.crop-cancel, .crop-use {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: #fff;
  padding: 6px 2px;
}
.crop-cancel { justify-self: start; opacity: 0.8; }
.crop-use { justify-self: end; font-weight: 650; color: var(--accent); }

/*
 * The viewport's exact pixel size is computed in JS (crop.js), not CSS: it needs to be
 * definite on both axes at once (as large as fits while staying exactly 3:4), and CSS
 * aspect-ratio only resolves a dimension left auto — with flex:1 driving height and
 * width:100% driving width, neither axis was auto, so the ratio was silently ignored.
 */
.crop-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* No padding here on purpose: crop.js measures clientWidth/clientHeight for the
     viewport math, and padding would count itself into that measurement, leaving width
     and height computed against different available space. The margin is a JS constant
     (CROP_STAGE_INSET) instead — one source of truth. */
}

.crop-viewport {
  position: relative;
  overflow: hidden;
  background: #111;
}

.crop-image {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none; /* our own pointer handlers do the panning; native scroll must not compete */
  user-select: none;
}

.crop-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.crop-zoom-icon { color: rgba(255, 255, 255, 0.6); flex: none; }
.crop-zoom-icon-sm { font-size: 14px; }
.crop-zoom-icon-lg { font-size: 22px; }
.crop-zoom {
  flex: 1;
  accent-color: var(--accent);
}

/* ---------- Photos ---------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 6px;
}
.photo-cell {
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell:active { transform: scale(0.97); }

.photo-actions { display: flex; gap: 10px; margin-top: 18px; }
.photo-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.upload-bar {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 6px;
  box-shadow: var(--shadow-sm);
}
.upload-label { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.upload-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.upload-fill { height: 100%; background: var(--accent); transition: width 0.15s linear; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(20, 16, 18, 0.94);
  display: grid;
  place-items: center;
  padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); }
.lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 19px;
  display: grid;
  place-items: center;
}

.nav-icon { font-size: 20px; color: var(--muted); }
.chev { color: var(--muted); opacity: 0.7; }

/* A share icon right on the row it describes — it used to live only inside the edit
   sheet, a screen away from the thing being shared. */
.row-share {
  border: none;
  background: none;
  color: var(--muted);
  flex: none;
  padding: 8px;
  margin: -8px;
  border-radius: 8px;
  display: flex;
}
.row-share .i { width: 17px; height: 17px; }
.row-share:active { background: var(--bg); color: var(--accent); }

/* ---------- Sign in ---------- */

body.signed-out .tabbar,
body.signed-out .ptr { display: none; }

.login {
  max-width: 340px;
  margin: 0 auto;
  padding: 14dvh 8px 0;
  text-align: center;
}
.login-icon { font-size: 34px; color: var(--muted); margin-bottom: 14px; }
.login h1 { font-family: var(--font-display); font-size: 27px; font-weight: 600; margin: 0 0 6px; }
.login p { margin: 0 0 22px; }
.login input {
  width: 100%;
  font-family: inherit;
  font-size: 19px;
  text-align: center;
  letter-spacing: 0.18em;
  padding: 15px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
}
.login input:focus { outline: none; border-color: var(--accent); }
.login-error { min-height: 20px; color: var(--accent); font-size: 13.5px; margin: 10px 0 4px; }
.login-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  padding: 15px;
}
.login-btn:disabled { opacity: 0.6; }

/* ---------- Misc ---------- */

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 4px;
}
.danger { color: #b3363b; }

.view-enter { animation: view-in 0.22s var(--ease); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- First-time tour ---------- */
/*
 * z-index sits above the crop overlay (100), the highest anything else on this screen
 * reaches, so a walkthrough step is never accidentally buried under something else mid-way
 * through onboarding.
 */
.tour-mask {
  position: fixed;
  z-index: 150;
  background: rgba(15, 12, 20, 0.72);
  pointer-events: auto;
}
.tour-ring {
  position: fixed;
  z-index: 151;
  border: 2px solid var(--accent);
  border-radius: 14px;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
/* Shown only when the highlighted element is still off screen after scrolling to it.
   Sits above the tooltip's z-index so it's never the thing that's hidden. */
.tour-hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 153;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 650;
  padding: 10px 18px;
  box-shadow: var(--shadow-md);
}
.tour-hint[hidden] { display: none; }
.tour-hint .i { width: 17px; height: 17px; }
.tour-hint.down { bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); }
.tour-hint.down .i { animation: hintNudge 1.4s ease-in-out infinite; }
/* Only a chevron-down exists in the sprite, so "up" is the same glyph flipped rather
   than a second icon to keep in sync. */
.tour-hint.up { top: calc(env(safe-area-inset-top, 0px) + 16px); }
.tour-hint.up .i { transform: rotate(180deg); animation: hintNudgeUp 1.4s ease-in-out infinite; }
@keyframes hintNudge { 50% { transform: translateY(3px); } }
@keyframes hintNudgeUp { 0%, 100% { transform: rotate(180deg); } 50% { transform: rotate(180deg) translateY(3px); } }

.tour-tip {
  position: fixed;
  z-index: 152;
  max-width: 360px;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 16px 18px;
}
.tour-step {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 4px;
}
.tour-tip h3 { font-size: 17px; margin: 0 0 6px; }
.tour-tip p { font-size: 14.5px; color: var(--muted); margin: 0 0 14px; line-height: 1.4; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tour-skip {
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 2px;
}
.tour-next {
  border: none;
  border-radius: 0.75rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  padding: 10px 18px;
}

/* ---------- Unfinished scans ----------
   Above the capture buttons, because an unfinished scan is the thing to deal with before
   starting another one. Styled as a list of resumable work, not a warning: nothing has
   gone wrong, someone just walked away mid-review. */
.unfinished { margin-bottom: 20px; }
.unfinished-h {
  font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 4px 8px;
}
.unfinished-r {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); text-align: left;
  font: inherit; color: var(--text); cursor: pointer;
}
.unfinished-r .t { display: block; font-size: 15.5px; font-weight: 600; }
.unfinished-r .s { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.unfinished-r .i { flex: none; opacity: 0.4; }

/* ---------- Pairing a screen ---------- */
/* The code is read off one screen and typed into another across the room, so it's set
   large, monospaced and widely tracked — the three things that stop 0/O and 1/I being
   guessed wrong. */
.pair-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 22px 12px;
  margin-bottom: 12px;
}
.pair-help { font-size: 13.5px; line-height: 1.5; color: var(--muted); margin: 0; }
.field-note { display: block; }

/* Destructive, but not the primary action on its row — a paired screen is far more often
   something you're checking on than something you're removing. */
.row-remove {
  border: 1px solid var(--border);
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  flex: none;
}

/* ---------- Guides (driver.js) ---------- */
/* The library ships neutral white; these overrides make its popover a Nook surface, in
   both themes, without touching its geometry - positioning is exactly the part we
   replaced our own code to stop owning. */
.driver-popover {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-family: "Inter", -apple-system, sans-serif;
  max-width: 320px;
}
.driver-popover-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}
.driver-popover-description { font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.driver-popover-progress-text { font-size: 12px; color: var(--muted); }
.driver-popover-navigation-btns button {
  font-family: inherit;
  font-weight: 650;
  border-radius: 999px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  text-shadow: none;
}
.driver-popover-navigation-btns button:last-child {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.driver-popover-arrow-side-top { border-top-color: var(--card); }
.driver-popover-arrow-side-bottom { border-bottom-color: var(--card); }
.driver-popover-arrow-side-left { border-left-color: var(--card); }
.driver-popover-arrow-side-right { border-right-color: var(--card); }

/* The you-are-here line: the answer to arriving on a screen without knowing how. */
.tour-where {
  display: block;
  width: fit-content;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

/* ---------- Guide motion ---------- */
.driver-popover {
  animation: guidePop 0.35s var(--ease);
  transition: left 0.32s var(--ease), top 0.32s var(--ease);
}
@keyframes guidePop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  .driver-popover { animation: none; transition: none; }
}

/* ---------- Completion feedback ---------- */
/* The tick lands with a small spring, then the row slides itself away - so completing
   something reads as an action with a result, not as a row winking out of existence. */
.checkbox.check-pop { animation: checkPop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes checkPop {
  0% { transform: scale(0.6); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.row-out {
  transition: opacity 0.19s ease, transform 0.19s ease;
  opacity: 0;
  transform: translateX(14px);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .checkbox.check-pop { animation: none; }
  .row-out { transition: none; }
}



/* ---------- The guide never blocks the app it's teaching ---------- */
/* driver.js ships `.driver-active * { pointer-events: none }` - the entire page goes
   inert while a tour runs, with only the highlighted element re-enabled. For a tour built
   on asking people to act (tap that tab, make that list, open it) that is exactly
   backwards: the instruction says act and the page says you may not. It blocked
   "+ New list" outright, so the first run dead-ended where a list was meant to be made,
   and it is the same fault that sealed the name chips shut earlier.
   Everything stays live; the overlay keeps dimming, purely as a visual cue. Tapping the
   backdrop to dismiss goes with it - the popover's close button is the affordance people
   actually use. Found by Playwright refusing a click and naming the interceptor. */
.driver-active * {
  pointer-events: auto !important;
}
/* ...except the dimming layer itself, which covers the whole screen. Re-enabling it along
   with everything else just moved the blockage from the page to the overlay. */
.driver-overlay,
.driver-overlay * {
  pointer-events: none !important;
}

/* ---------- Sheets during a guide ---------- */
/* driver.js parks its overlay at z-index 1000000000, which put every sheet opened during
   a tour behind it: the tour could say "tap + New list", the sheet would open, and its
   Create button was unclickable. Caught by Playwright reporting the overlay intercepting
   pointer events - a synthetic click would have sailed straight through and passed.
   Sheets sit above the overlay while one is open, so any step that opens a sheet stays
   usable without the tour needing to know which steps those are. */
body.sheet-locked .sheet-backdrop,
body.sheet-locked .sheet {
  z-index: 1000000001;
}

/* ---------- Recipe → meal plan ---------- */
.meal-add {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--card); border-radius: var(--radius-md);
  padding: 14px; margin-top: 18px; box-shadow: var(--shadow-sm);
}
.meal-add input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.meal-add-t { display: block; font-size: 15.5px; font-weight: 600; }
.meal-add-s { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.meal-date { width: 100%; margin-top: 8px; }
