:root {
  /* ---- Brand / accent ramp ---- */
  --accent:        #0e9f6e;  /* identity: tints, checks, borders, progress, glow. UI-only (>=3:1) */
  --accent-strong: #0a8159;  /* NEW: fill under WHITE text — buttons, add btn, filled badges (4.89:1) */
  --accent-dark:   #057a55;  /* accent-as-TEXT: prices, chip-more, due, count, :active fill (5.36:1 on card) */
  --accent-soft:   #def7ec;  /* soft container: chips active, qty pill, share-code, count bg */
  --accent-glow:   rgba(14,159,110,.35); /* NEW: raw tint for glow stacks */
  --on-accent:     #ffffff;  /* NEW: text/glyph that sits on --accent-strong / :active fills */

  /* ---- Surface tiers ---- */
  --bg:            #f4f6f5;  /* app background */
  --card:          #ffffff;  /* solid cards & rows (stay opaque for readability) */
  --elevated:      #ffffff;  /* raised solid surfaces (popover autocomplete, celebration) */
  --glass-soft:    rgba(237,244,240,.72); /* NEW: W2 — headers, banners, chips row */
  --glass-strong:  rgba(240,245,242,.82); /* NEW: W2 — toolbar, sheets, snackbar */
  --glass-fallback:#eef3f0;  /* NEW: W2 solid fallback when backdrop-filter unsupported */
  --scrim:         rgba(16,32,27,.42);    /* NEW: overlay behind sheets (green-black, not pure) */

  /* ---- Text ---- */
  --text:          #16201b;  /* 16.7:1 on card */
  --muted:         #617068;  /* was #6b7a72 — darkened for AA on bg+glass (see §4) */
  --done:          #79887f;  /* was #9aa8a0 — darkened to reach 3:1 disabled-min (see §4) */

  /* ---- Lines / hairlines ---- */
  --line:          #e3e8e5;  /* standard divider */
  --line-strong:   #d3dbd7;  /* NEW: heavier separators (menu-divider, sheet edges) */
  --hairline-spec: rgba(255,255,255,.55); /* NEW: specular top edge on glass (W2) */

  /* ---- Status ---- */
  --danger:        #e02424;

  /* ---- Shadow scale (ambient + key, green-black undertone) ---- */
  --shadow-1: 0 1px 2px rgba(16,32,27,.06), 0 1px 3px rgba(16,32,27,.10);
  --shadow-2: 0 2px 4px rgba(16,32,27,.06), 0 4px 10px rgba(16,32,27,.10);
  --shadow-3: 0 4px 8px rgba(16,32,27,.08), 0 12px 24px rgba(16,32,27,.13);
  --shadow-4: 0 8px 16px rgba(16,32,27,.10), 0 24px 48px rgba(16,32,27,.16);
  --shadow-inset: inset 0 2px 4px rgba(16,32,27,.12);  /* pressed / recessed */
  --glow-accent:    0 2px 6px rgba(14,159,110,.28), 0 6px 18px rgba(14,159,110,.32);
  --glow-accent-sm: 0 1px 4px rgba(14,159,110,.30);
  --glow-accent-lg: 0 8px 24px rgba(14,159,110,.35);   /* = current setup-logo seed */

  /* ---- Radius scale (16px stays the default feel) ---- */
  --radius-s:  10px;  /* inputs, thumbs, qty pill, stepper */
  --radius-m:  16px;  /* cards, rows — the default */
  --radius-l:  22px;  /* sheets, large surfaces */
  --radius-xl: 28px;  /* hero logos, celebration card */
  --radius:    var(--radius-m);   /* legacy alias — unchanged behaviour */
  --radius-pill: 999px;

  /* ---- Legacy alias (keeps every existing box-shadow:var(--shadow) working) ---- */
  --shadow: var(--shadow-1);

  /* ---- Motion tokens (W3 scaffolding — inert in W1) ---- */
  --dur-1: 140ms;  /* micro: tap ripple, chip select, tick pop */
  --dur-2: 180ms;  /* default: item entrance, snackbar */
  --dur-3: 240ms;  /* sheets, screen cross-fade */
  --dur-4: 300ms;  /* screen slide, celebration */
  --ease-standard:    cubic-bezier(0.2, 0, 0, 1);
  --ease-emph-decel:  cubic-bezier(0.05, 0.7, 0.1, 1);   /* entrances (M3 emphasized-decelerate) */
  --ease-emph-accel:  cubic-bezier(0.3, 0.0, 0.8, 0.15); /* exits */
  --ease-spring:      cubic-bezier(0.2, 1.4, 0.35, 1);   /* sheet/pop overshoot (aligns to current celebration curve) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent:        #31c48d;
    --accent-strong: #31c48d;  /* bright fill; text is dark --on-accent */
    --accent-dark:   #0e9f6e;  /* deeper green: gradients, :active fill */
    --accent-soft:   #123c2d;
    --accent-glow:   rgba(49,196,141,.40);
    --on-accent:     #07130d;  /* NEW: dark glyph/text on bright accent fill (8.49:1) */

    --bg:            #101913;
    --card:          #1a241e;
    --elevated:      #223029;
    --glass-soft:    rgba(18,29,22,.72);
    --glass-strong:  rgba(16,25,19,.82);
    --glass-fallback:#141d17;
    --scrim:         rgba(0,0,0,.58);

    --text:          #e8efe9;
    --muted:         #8fa297;   /* passes AA everywhere in dark — unchanged */
    --done:          #6a7c71;   /* was #5d6e64 — nudged to 3:1 disabled-min */

    --line:          #2a362e;
    --line-strong:   #35443b;
    --hairline-spec: rgba(255,255,255,.12);

    --shadow-1: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.45);
    --shadow-2: 0 2px 4px rgba(0,0,0,.38), 0 4px 10px rgba(0,0,0,.48);
    --shadow-3: 0 4px 8px rgba(0,0,0,.42), 0 12px 24px rgba(0,0,0,.55);
    --shadow-4: 0 8px 16px rgba(0,0,0,.48), 0 24px 48px rgba(0,0,0,.62);
    --shadow-inset: inset 0 2px 4px rgba(0,0,0,.45);
    --glow-accent:    0 2px 6px rgba(49,196,141,.30), 0 6px 20px rgba(49,196,141,.36);
    --glow-accent-sm: 0 1px 4px rgba(49,196,141,.34);
    --glow-accent-lg: 0 8px 26px rgba(49,196,141,.40);

    --shadow: var(--shadow-1);
  }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 0; box-shadow: 0 0 0 3px var(--accent-soft); }

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

/* iOS: stop long-press from firing the text-selection callout, and make the
   chrome feel native (the long-press menu is handled in JS instead). Inputs
   and the share code stay selectable. */
button, .item-row, .toolbar, .chips-row-wrap, .list-header, .home-header,
.cat-title, .sheet h2, .home-list-card, .type-card, .meal-row {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, .share-code { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100%;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
input, select {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 13px 14px;
  width: 100%;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
select { width: auto; max-width: 60%; padding: 10px 12px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.brand-row { display: flex; align-items: center; gap: 12px; }
.logo-img { width: 44px; height: 44px; border-radius: 12px; }
.setup-logo-img {
  width: 96px; height: 96px;
  border-radius: var(--radius-xl);
  box-shadow: var(--glow-accent-lg);
}
.small-print a { color: var(--muted); }

.wordmark {
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--accent), var(--accent-dark));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}

/* ===== Setup ===== */
#screen-setup { justify-content: center; padding: 24px; }
.setup-card { text-align: center; }
.setup-logo {
  width: 84px; height: 84px;
  margin: 0 auto 4px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 48px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-accent-lg);
}
.setup-card h1 { margin: 14px 0 10px; font-size: 32px; letter-spacing: -0.02em; }
.setup-card p { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }
.setup-card input { text-align: center; font-size: 20px; margin-bottom: 14px; }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 17px;
  font-weight: 600;
}
.btn-primary { background: var(--accent-strong); color: var(--on-accent); box-shadow: var(--glow-accent); }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-dark); margin-top: 10px; box-shadow: var(--shadow-1); }
@media (prefers-color-scheme: dark) { .btn-secondary { color: var(--accent); } }
/* Ripple hosts (W3). Declared BEFORE .drag-ghost so the ghost's
   position:fixed still wins the cascade for lifted home cards. */
.btn-primary, .btn-secondary, .home-list-card, .chip, .toolbar-btn, .type-card, .stepper-btn {
  position: relative;
  overflow: hidden;
}

.btn-ghost {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
}
.btn-kebab { font-size: 26px; font-weight: 700; letter-spacing: 0; padding: 4px 16px; }
.btn-ghost-wide, .btn-danger-ghost {
  width: 100%;
  background: none;
  border: none;
  padding: 14px;
  font-size: 16px;
  color: var(--text);
  margin-top: 4px;
  text-align: center;
}
.btn-danger-ghost { color: var(--danger); }
.menu-divider { height: 1px; background: var(--line); margin: 14px 0 6px; }
.small-print {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 14px 2px 0;
  text-align: center;
}

/* ===== Home ===== */
#screen-home { padding: 24px 20px; }
.home-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.home-header h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; font-weight: 800; }
.home-header p { margin: 2px 0 0; }
.home-lists { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.home-list-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  font-size: 17px;
  color: var(--text);
  text-align: left;
}
.home-list-card:active { box-shadow: var(--shadow-2); }
.home-list-card .emoji { font-size: 26px; }
.home-list-card .meta { flex: 1; }
.home-list-card .meta small { display: block; color: var(--muted); margin-top: 2px; }
.home-list-card .count {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
}
/* Long-press drag to reorder: the ghost follows the finger, the real card
   stays in the flow as a faded placeholder. */
.drag-ghost {
  position: fixed;
  z-index: 80;
  margin: 0;
  pointer-events: none;
  transform: scale(1.03);
  box-shadow: var(--shadow-3);
}
.drag-placeholder { opacity: .35; }

.home-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 10px;
  line-height: 1.6;
}
.home-hint { text-align: center; font-size: 13px; line-height: 1.5; margin-top: 18px; }

/* ===== New list type grid ===== */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 4px;
}
.type-card {
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 6px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.type-card .t-emoji { font-size: 26px; }
.type-card.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; box-shadow: var(--glow-accent-sm); }

/* ===== Settings ===== */
.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 14px; }
.field-label input { margin-top: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 2px 8px; }
.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 14px;
}
.plan-name { font-weight: 600; font-size: 16px; }
.plan-sub { font-size: 12.5px; margin-top: 2px; }
.plan-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--line);
  color: var(--muted);
}
.plan-badge.plus { background: var(--accent-strong); color: var(--on-accent); }

/* ===== Kitoodle Plus paywall ===== */
.plus-cta { margin-top: 12px; }
.plus-hero { text-align: center; padding: 4px 0 6px; }
.plus-logo {
  width: 60px; height: 60px;
  margin: 0 auto 8px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-accent);
}
.plus-hero h2 { margin: 0; font-size: 24px; }
.plus-benefits { list-style: none; padding: 0; margin: 14px 0 18px; }
.plus-benefits li {
  font-size: 16px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
}
.plus-benefits li:last-child { border-bottom: none; }
.plus-options { display: flex; flex-direction: column; gap: 10px; }
.plus-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 15px 16px;
  color: var(--text);
}
.plus-option .po-main { display: flex; flex-direction: column; }
.plus-option .po-title { font-weight: 700; font-size: 17px; }
.plus-option .po-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.plus-option .po-price { font-weight: 800; font-size: 18px; color: var(--accent-dark); white-space: nowrap; }
@media (prefers-color-scheme: dark) { .plus-option .po-price { color: var(--accent); } }
.plus-option.best { border-color: var(--accent); box-shadow: var(--glow-accent-sm); }
.plus-option .po-tag {
  position: absolute;
  transform: translateY(-26px);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  border-radius: 999px;
  padding: 3px 9px;
}
.plus-status-msg { text-align: center; font-size: 14px; margin: 12px 0 0; }
.plus-status-msg.err { color: var(--danger); }
.swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  padding: 0;
}
.swatch.selected { border-color: var(--text); }

/* ===== Switch ===== */
.switch {
  width: 52px; height: 32px;
  border-radius: 99px;
  border: none;
  background: var(--line);
  position: relative;
  transition: background .2s;
  flex: 0 0 auto;
}
.switch .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: left .2s;
}
.switch[aria-checked="true"] { background: var(--accent); box-shadow: var(--glow-accent-sm); }
.switch[aria-checked="true"] .knob { left: 23px; }
.field-pair { display: flex; gap: 10px; margin-top: 10px; }
.field-pair label { flex: 1; font-size: 13px; font-weight: 600; color: var(--muted); }
.field-pair input { margin-top: 5px; }

/* ===== List header ===== */
/* W2 liquid glass: sticky so content scrolls beneath the frost; saturate >1
   lets the app's green bloom through instead of washing grey. */
.list-header {
  display: flex;
  align-items: center;
  padding: 10px 8px 6px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--glass-soft);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: inset 0 1px 0 var(--hairline-spec), 0 1px 0 var(--line);
}
.list-header h1 { font-size: 21px; margin: 0; }
.list-title-wrap { flex: 1; min-width: 0; }
.list-title-wrap h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-back { font-size: 32px; line-height: 1; padding: 4px 14px; }

.presence { display: flex; gap: 4px; align-items: center; min-height: 16px; }
.presence .avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.presence .avatar.idle { background: var(--done); }
.presence .plabel { font-size: 12px; color: var(--muted); margin-left: 2px; }

.sync-status {
  text-align: center;
  font-size: 12.5px;
  padding: 6px 12px;
  background: #fff7e6;
  color: #92610a;
}
@media (prefers-color-scheme: dark) { .sync-status { background: #2e2410; color: #e3b341; } }

/* ===== Progress & budget ===== */
.shop-progress { padding: 6px 20px 2px; }
.shop-progress-text { font-size: 13px; color: var(--muted); margin-bottom: 5px; text-align: center; }
.shop-progress-track { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; }
.shop-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 99px;
  box-shadow: var(--glow-accent-sm);
  transition: width .4s ease;
}
.budget-bar { padding: 8px 20px 2px; }
.budget-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.budget-row span:first-child { font-weight: 700; }
.budget-fill-over { background: var(--danger) !important; }
.price-input { width: 110px !important; text-align: right; }
.date-input { width: auto !important; }
.due-tag { font-weight: 600; color: var(--accent-dark); }
@media (prefers-color-scheme: dark) { .due-tag { color: var(--accent); } }
.due-tag.soon { color: #b45309; }
.due-tag.overdue { color: var(--danger); }

/* ===== Add bar ===== */
.add-bar { display: flex; gap: 8px; padding: 10px 16px 4px; align-items: center; }
.add-bar-inline { padding: 10px 0 4px; }
.add-bar input { flex: 1; }
.btn-round {
  flex: 0 0 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  box-shadow: var(--shadow-2);
  font-size: 20px;
  color: var(--text);
}
.btn-add { background: var(--accent-strong); color: var(--on-accent); font-size: 26px; box-shadow: var(--glow-accent); }

.autocomplete {
  margin: 0 16px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.autocomplete button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
}
.autocomplete button:last-child { border-bottom: none; }

/* ===== Chips ===== */
.chips-row-wrap { display: flex; align-items: center; padding: 8px 0 4px 16px; gap: 6px; }
.chips-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14.5px;
  white-space: nowrap;
  transition: background var(--dur-1) var(--ease-standard),
              border-color var(--dur-1) var(--ease-standard),
              transform var(--dur-1) var(--ease-standard);
}
.chip:active { background: var(--accent-soft); border-color: var(--accent); transform: scale(.94); }
.chip-more { margin-right: 12px; color: var(--accent-dark); border-color: transparent; background: none; font-weight: 600; }
@media (prefers-color-scheme: dark) { .chip-more { color: var(--accent); } }

/* ===== Items ===== */
.items-area { flex: 1; padding: 8px 16px 90px; }
.cat-section { margin-bottom: 14px; }
.cat-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 10px 4px 7px;
}
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 13px 14px;
  margin-bottom: 8px;
  animation: slidein var(--dur-2) var(--ease-emph-decel);
}
@keyframes slidein { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.item-check {
  flex: 0 0 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: none;
  font-size: 15px;
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform var(--dur-1) var(--ease-standard);
}
.item-check:active { transform: scale(.85); }
.item-row.done .item-check { background: var(--accent); border-color: var(--accent); box-shadow: var(--glow-accent-sm); }
.item-emoji { font-size: 22px; flex: 0 0 auto; }
.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 16.5px; font-weight: 500; overflow-wrap: anywhere; }
.item-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.item-qty {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 13px;
  border-radius: 8px;
  padding: 2px 8px;
  margin-right: 6px;
}
@media (prefers-color-scheme: dark) { .item-qty { color: var(--accent); } }
.item-thumb {
  width: 40px; height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid var(--line);
}
.item-more {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  padding: 6px 8px;
}
.item-row.done .item-name { text-decoration: line-through; color: var(--done); }
.item-row.done .item-emoji { filter: grayscale(1); opacity: .6; }
.item-row.done { box-shadow: none; background: transparent; border: 1.5px dashed var(--line); }

.done-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 4px 7px;
}
.empty-state { text-align: center; color: var(--muted); padding: 48px 24px; line-height: 1.6; }
.empty-state .big { font-size: 52px; display: block; margin-bottom: 8px; }

/* ===== Photo row & viewer ===== */
.photo-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.photo-row .btn-secondary { flex: 1; margin-top: 0; }
.photo-row .btn-danger-ghost { width: auto; margin: 0; padding: 10px; }
.photo-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); }
.scan-preview {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 14px;
  margin: 8px 0 4px;
  background: var(--bg);
}
.scan-status-text { text-align: center; font-size: 14px; margin: 4px 0 0; }
.scan-spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.photo-viewer img { max-width: 94vw; max-height: 80dvh; border-radius: 14px; }
.photo-viewer-caption { color: #fff; font-size: 17px; font-weight: 600; }

/* ===== Meals ===== */
.meals-body { padding: 6px 0 4px; }
.meal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
}
.meal-row .m-emoji { font-size: 24px; }
.meal-row .m-main { flex: 1; min-width: 0; }
.meal-row .m-name { font-weight: 600; font-size: 16px; }
.meal-row .m-sub { font-size: 12.5px; color: var(--muted); }
.meal-row .m-add {
  border: none;
  background: var(--accent-strong);
  color: var(--on-accent);
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 13px;
}
.meal-row .m-edit { background: none; border: none; color: var(--muted); font-size: 18px; padding: 6px; }
.meal-ings { padding: 8px 0; }
.meal-ing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15.5px;
}
.meal-ing-row .ing-name { flex: 1; }
.meal-ing-row .ing-del { background: none; border: none; color: var(--danger); font-size: 17px; padding: 4px 8px; }

/* ===== Shopping mode ===== */
body.shopping .item-row { padding: 18px 16px; }
body.shopping .item-name { font-size: 19px; }
body.shopping .item-check { flex-basis: 32px; height: 32px; }
body.shopping .chips-row-wrap, body.shopping .autocomplete { display: none; }
body.shopping #btn-shopping-mode { color: var(--accent); }

/* ===== Toolbar ===== */
.toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  backdrop-filter: blur(28px) saturate(1.8);
  box-shadow: inset 0 1px 0 var(--hairline-spec), 0 -6px 20px rgba(16, 32, 27, .07);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  .toolbar { box-shadow: inset 0 1px 0 var(--hairline-spec), 0 -6px 20px rgba(0, 0, 0, .4); }
}
.toolbar-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 9px 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.toolbar-ico { font-size: 21px; }

/* ===== Sheets ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 40;
}
.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
  backdrop-filter: blur(28px) saturate(1.8);
  border-radius: 22px 22px 0 0;
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  animation: sheetup var(--dur-3) var(--ease-spring);
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 var(--hairline-spec), var(--shadow-4);
}
@keyframes sheetup { from { transform: translateY(40%); opacity: .5; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
.sheet .btn-primary, .sheet .btn-secondary { margin-top: 10px; }
.sheet input { margin-top: 12px; }
.sheet .add-bar input, .sheet .qty-row input, .sheet .field-pair input { margin-top: 0; }
.sheet-tall { height: 85dvh; }

.share-code {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: .25em;
  text-align: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: 14px;
  padding: 18px 10px 18px 18px;
  margin: 16px 0 6px;
  user-select: all;
}
@media (prefers-color-scheme: dark) { .share-code { color: var(--accent); } }

.qty-row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 16px; gap: 12px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 22px;
}
#qty-value { min-width: 44px; text-align: center; font-size: 19px; font-weight: 700; }

.catalog-body { padding-top: 6px; }
.catalog-cat-title { font-size: 14px; font-weight: 700; margin: 16px 2px 8px; }
.catalog-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.catalog-grid .chip.on-list { background: var(--accent-soft); border-color: var(--accent); }

.activity-body { padding: 8px 0; }
.activity-row { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.activity-row .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; margin-left: auto; }

/* ===== Snackbar ===== */
/* Toast stays dark in both themes (convention); glassified with a dark
   green tint so content glows through without hurting the white text. */
.snackbar {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  max-width: 520px;
  margin: 0 auto;
  background: rgba(30, 41, 35, .78);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  color: #fff;
  border-radius: 12px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 60;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-3);
  animation: slidein var(--dur-2) var(--ease-emph-decel);
}
.snackbar button {
  background: none;
  border: none;
  color: #4ade80;
  font-weight: 700;
  font-size: 15px;
  padding: 4px 8px;
}

/* ===== Native update banner (Android app only) ===== */
.update-banner {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  max-width: 520px;
  margin: 0 auto;
  background: rgba(30, 41, 35, .78);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  z-index: 59; /* one under the snackbar so transient toasts stay readable */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), var(--shadow-3);
  animation: slidein var(--dur-2) var(--ease-emph-decel);
}
.update-banner button { background: none; border: none; }
#update-banner-go {
  flex: 1;
  text-align: left;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 13px 8px 13px 16px;
}
#update-banner-close {
  color: #9ca3af;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 14px;
}

/* ===== Celebration ===== */
.celebration {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  pointer-events: none;
}
.celebration-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .25);
  padding: 28px 36px;
  text-align: center;
  font-size: 22px;
  line-height: 1.5;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  z-index: 65;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105dvh) rotate(540deg); opacity: .9; }
}

/* ===== Motion (W3) ===== */
/* Home<->List screen transition. app.js sets html[data-nav] and calls
   startViewTransition; these rules shape it. Unsupported browsers never
   create the pseudo-elements, so this block is inert there. */
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: var(--dur-4);
  animation-timing-function: var(--ease-emph-decel);
}
html[data-nav="fwd"]::view-transition-new(root) { animation-name: vt-in-right; }
html[data-nav="fwd"]::view-transition-old(root) { animation-name: vt-out-left; }
html[data-nav="back"]::view-transition-new(root) { animation-name: vt-in-left; }
html[data-nav="back"]::view-transition-old(root) { animation-name: vt-out-right; }
@keyframes vt-in-right { from { opacity: 0; transform: translateX(16px); } }
@keyframes vt-out-left { to { opacity: 0; transform: translateX(-16px); } }
@keyframes vt-in-left { from { opacity: 0; transform: translateX(-16px); } }
@keyframes vt-out-right { to { opacity: 0; transform: translateX(16px); } }

/* Staggered row entrance on list open only (app.js toggles .entering).
   Capped at 8 steps; later rows arrive together with the last step. */
.items-area.entering .item-row { animation: slidein var(--dur-2) var(--ease-emph-decel) both; }
.items-area.entering .item-row:nth-child(2) { animation-delay: 34ms; }
.items-area.entering .item-row:nth-child(3) { animation-delay: 68ms; }
.items-area.entering .item-row:nth-child(4) { animation-delay: 102ms; }
.items-area.entering .item-row:nth-child(5) { animation-delay: 136ms; }
.items-area.entering .item-row:nth-child(6) { animation-delay: 170ms; }
.items-area.entering .item-row:nth-child(7) { animation-delay: 204ms; }
.items-area.entering .item-row:nth-child(n+8) { animation-delay: 238ms; }

/* Tap ripple (span injected by ripple.js) */
.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: .18;
  transform: scale(0);
  animation: ripple 420ms var(--ease-standard);
}
@keyframes ripple { to { transform: scale(2.4); opacity: 0; } }

/* ===== Liquid glass: budget gate & fallback (W2) ===== */
/* Perf budget: max 2 concurrent blur layers (low-end Android WebView). While a
   sheet is open its scrim hides the chrome, so header/toolbar drop their blur
   and the open sheet becomes the only expensive layer. Progressive: without
   :has() support this rule is skipped and things still render correctly. */
body:has(.sheet:not(.hidden)) .list-header,
body:has(.sheet:not(.hidden)) .toolbar {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--glass-fallback);
}
/* Solid fallback when backdrop-filter is unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .list-header, .toolbar, .sheet { background: var(--glass-fallback); }
  .snackbar, .update-banner { background: #232d27; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important; /* stagger delays must collapse too */
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .confetti, .ripple { display: none !important; }
  /* View Transitions are also skipped in JS (show() guard in app.js). */
}

/* ===== App-only gating: browser "get the app" affordances =====
   [hidden] must beat the display rules on .btn-primary etc., otherwise
   toggling the New list / Get the app pair leaves both on screen. */
[hidden] { display: none !important; }

/* Anchor styled as the primary button, so the Play link sits in the home
   actions row exactly where "＋ New list" does in the app. */
.btn-getapp {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* Play link inside the Plus sheet, where the purchase options normally go. */
.install-cta { text-decoration: none; }

/* ===== Landing (first-time browser visitors + search engines; never in the app) ===== */
.landing {
  display: block;               /* a readable page, not the app's flex column */
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  line-height: 1.55;
}
.landing.hidden { display: none !important; }
.landing-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.landing-brand .wordmark { font-size: 22px; }
.landing h1 { font-size: 30px; line-height: 1.18; letter-spacing: -0.02em; margin: 0 0 12px; }
.landing h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 10px; }
.landing-lede { font-size: 18px; margin: 0 0 20px; }
.landing-cta { margin-bottom: 12px; }
.landing-note { font-size: 14.5px; margin: 0 0 30px; }
.landing-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-1);
  padding: 18px 18px 8px;
  margin-bottom: 16px;
}
.landing-block p { margin: 0 0 10px; }
.landing-list { margin: 0; padding-left: 20px; }
.landing-list li { margin-bottom: 10px; }
.landing-faq { margin: 0; }
.landing-faq dt { font-weight: 700; margin-top: 4px; }
.landing-faq dd { margin: 2px 0 12px; color: var(--muted); }
.landing a:not(.btn-primary) { color: var(--accent-dark); }
.landing-foot { text-align: center; font-size: 14px; color: var(--muted); margin-top: 24px; }
.landing-foot p { margin: 0 0 6px; }
@media (prefers-color-scheme: dark) { .landing a:not(.btn-primary) { color: var(--accent); } }
