:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --ink: #262626;
  --ink-2: #3a3a3c;
  --muted: #8e8e93;
  --muted-2: #b5b5ba;
  --line: #ececef;
  --chip: #efeff1;

  --green: #38c23c;
  --green-ink: #2fae33;
  --green-soft: #e8f8e7;
  --pink: #f7378f;
  --pink-soft: #fdedf4;
  --blue: #1f6fe5;
  --blue-soft: #e9f1fe;
  --red: #e5484d;
  --red-soft: #fdecec;
  --navy: #2f3a4e;

  --cat-grocery: #fff8ee;
  --cat-dairy: #eaf3fe;
  --cat-fruits: #fdeef0;
  --cat-other: #f7f1fc;

  --shadow-card: 0 6px 22px rgba(20, 20, 40, 0.06), 0 1px 3px rgba(20, 20, 40, 0.04);
  --shadow-float: 0 4px 14px rgba(20, 20, 40, 0.10);
  --radius-card: 24px;
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; flex: none; }

/* ------------------------------------------------------------ screen */
.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px calc(var(--nav-h) + var(--safe-b) + 48px);
  min-height: 100vh;
  animation: screen-in .22s var(--ease);
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

/* Home header */
.greet { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 30px; }
.greet small { display: block; color: var(--muted); font-size: 14px; }
.greet h1 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -0.2px; line-height: 1.2; }
.greet-actions { display: flex; gap: 12px; align-items: center; }
.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-float);
  display: grid; place-items: center; color: var(--muted);
  transition: transform .15s var(--ease);
}
.round-btn:active { transform: scale(.94); }
.round-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-btn {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  border: 3px solid #fff; box-shadow: var(--shadow-float); background: #cfe4f7;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 30px; }
.stat {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow-card);
  padding: 15px 6px 13px; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.stat-num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.stat-label { font-size: 10.5px; letter-spacing: 1.6px; color: var(--muted); font-weight: 500; text-transform: uppercase; }
.stat.total .stat-num { background: var(--blue-soft); color: var(--blue); }
.stat.fav .stat-num { background: var(--pink-soft); color: var(--pink); }
.stat.done .stat-num { background: var(--green-soft); color: var(--green); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; }
.section-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.link-btn { color: var(--green); font-weight: 600; font-size: 14.5px; padding: 6px 2px; }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 34px; }
.cat-tile {
  display: flex; align-items: center; gap: 12px; text-align: left;
  height: 56px; padding: 0 16px; border-radius: 18px;
  font-weight: 600; font-size: 16px; color: var(--ink);
  transition: transform .15s var(--ease);
}
.cat-tile:active { transform: scale(.97); }
.cat-tile .emoji { font-size: 22px; line-height: 1; }
.cat-tile[data-cat="Grocery"] { background: var(--cat-grocery); }
.cat-tile[data-cat="Dairy"] { background: var(--cat-dairy); }
.cat-tile[data-cat="Fruits"] { background: var(--cat-fruits); }
.cat-tile[data-cat="Other"] { background: var(--cat-other); }

.trash-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-card);
  padding: 12px 14px; margin: -14px 0 30px;
}
.trash-link .ico { width: 36px; height: 36px; border-radius: 12px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; }
.trash-link b { display: block; font-weight: 600; font-size: 14.5px; }
.trash-link span { color: var(--muted); font-size: 12.5px; }
.trash-link .chev { margin-left: auto; color: var(--muted-2); }

/* Page header (Favorites / Personas / etc) */
.page-head { display: flex; align-items: center; gap: 16px; margin: 0 0 34px; }
.back-btn {
  width: 42px; height: 42px; border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow-float); display: grid; place-items: center; color: var(--muted); flex: none;
}
.head-tile { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px rgba(0,0,0,.04); }
.head-tile.pink { background: var(--pink-soft); color: var(--pink); }
.head-tile.green { background: var(--green-soft); color: var(--green); font-weight: 700; font-size: 20px; }
.head-tile.red { background: var(--red-soft); color: var(--red); }
.head-tile.blue { background: var(--blue-soft); color: var(--blue); }
.page-head h1 { margin: 0; font-size: 25px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.page-head .grow { flex: 1; min-width: 0; }
.head-actions { display: flex; gap: 8px; }
.icon-chip { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow-float); color: var(--muted); }
.icon-chip.danger { background: var(--red-soft); color: var(--red); box-shadow: none; }

/* List screen */
.search {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 22px; box-shadow: var(--shadow-card); padding: 0 18px; height: 54px; margin-bottom: 22px;
}
.search svg { color: var(--muted); }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font-size: 16px; height: 100%; }
.search input::placeholder { color: var(--muted); }
.search .clear { color: var(--muted); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 14px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 19px; border-radius: 999px;
  background: var(--card); color: var(--muted); font-weight: 600; font-size: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05); transition: background .2s, color .2s, box-shadow .2s;
}
.chip[aria-pressed="true"] { background: var(--green); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--green) 35%, transparent); }
.list-meta { display: flex; justify-content: space-between; align-items: center; margin: 0 0 16px; }
.list-meta .count { color: var(--muted); font-size: 15px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 999px; background: var(--green-soft); color: var(--green); font-weight: 600; font-size: 15px;
}

.hidden-note {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--chip); color: var(--ink-2); border-radius: 14px; padding: 8px 8px 8px 14px; font-size: 13px; margin-bottom: 16px;
}
.hidden-note button { color: var(--green-ink); font-weight: 600; padding: 6px 10px; border-radius: 10px; }

/* ------------------------------------------------------------ item card */
.cards { display: flex; flex-direction: column; gap: 22px; padding: 0 0 0 0; }
.card {
  position: relative; display: flex; align-items: stretch;
  background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  min-height: 110px; padding: 10px 0 10px 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.card.leaving { opacity: 0; transform: translateX(16px) scale(.98); }
.card-body { flex: 1; min-width: 0; padding: 4px 12px 2px 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; }
.card-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; }
.qty {
  justify-self: start; min-width: 28px; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--chip); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px;
}
.qty:hover { background: #e4e4e8; }
.cat { text-align: center; font-size: 11px; letter-spacing: 1.6px; color: var(--muted); font-weight: 500; text-transform: uppercase; }
.price { font-weight: 600; font-size: 13px; color: var(--ink-2); text-align: right; }
.name {
  display: block; width: 100%; text-align: center; font-weight: 700; font-size: 16.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 3px 0; border-radius: 8px;
}
.vendor { text-align: center; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check, .heart {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s;
}
.check:active, .heart:active { transform: scale(.88); }
.check { background: var(--chip); color: var(--muted-2); justify-self: start; }
.check[aria-pressed="true"] { background: var(--green); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent), 0 6px 14px color-mix(in srgb, var(--green) 40%, transparent); }
.heart { background: var(--chip); color: var(--muted-2); justify-self: end; }
.heart[aria-pressed="true"] { background: var(--pink-soft); color: var(--pink); }
.heart[aria-pressed="true"] svg { animation: pop .3s var(--ease); }
@keyframes pop { 50% { transform: scale(1.25); } }

.thumb {
  flex: none; width: 92px; align-self: stretch; margin-right: 0; border-radius: 16px 0 0 16px;
  background: #f2f2f4; display: grid; place-items: center; color: #d0d0d5; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-persona {
  position: absolute; left: -12px; top: 50%; margin-top: -16px;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: #f4f4f6; color: var(--muted-2); border: 2px solid #fff; box-shadow: var(--shadow-float);
}
.card-persona.on { background: var(--green-soft); color: var(--green); }
.card-persona .badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--green); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.card-fab {
  position: absolute; right: -8px; width: 32px; height: 32px; border-radius: 50%;
  background: #fff; color: #8e8e93; display: grid; place-items: center; box-shadow: var(--shadow-float);
}
.card-fab.x { top: -10px; }
.card-fab.min { bottom: -10px; }
.card-fab:hover { color: var(--ink); }

/* Completed: everything fades except the green check */
.card.is-done { background: #fdfdfd; }
.card.is-done :is(.qty, .cat, .price, .name, .vendor, .heart, .thumb, .card-persona) { opacity: .5; }
.card.is-done .name { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }

/* ------------------------------------------------------------ empty / loading / error */
.empty {
  text-align: center; padding: 38px 24px; background: var(--card); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); color: var(--muted);
}
.empty .ico { width: 58px; height: 58px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.empty.pink .ico { background: var(--pink-soft); color: var(--pink); }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 280px; font-size: 14px; }
.empty .btn { margin-top: 18px; }

.skeleton { background: linear-gradient(90deg, #ececef 25%, #f5f5f7 50%, #ececef 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.boot { display: grid; place-items: center; min-height: 70vh; text-align: center; color: var(--muted); }
.boot .logo { width: 64px; height: 64px; border-radius: 20px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 0 auto 14px; }

/* ------------------------------------------------------------ personas */
.add-persona {
  display: flex; align-items: center; gap: 22px; width: 100%; text-align: left;
  border: 2px dashed #e6e6ea; border-radius: var(--radius-card); background: var(--card);
  padding: 16px 20px; color: var(--green); font-weight: 600; font-size: 18px; margin-bottom: 26px;
}
.add-persona .plus { width: 52px; height: 52px; border-radius: 50%; background: var(--green-soft); display: grid; place-items: center; }
.persona-list { display: flex; flex-direction: column; gap: 14px; }
.persona-row {
  display: flex; align-items: center; background: var(--card); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 14px 16px 14px 14px; gap: 12px;
}
.persona-open { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; text-align: left; padding: 2px; border-radius: 16px; }
.initial { width: 52px; height: 52px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 700; font-size: 19px; flex: none; }
.persona-open b { display: block; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.persona-open .txt span { color: var(--muted); font-size: 14px; }
.persona-open .txt { flex: 1; min-width: 0; }
.persona-open .chev { color: var(--muted); }
.del-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; flex: none; }

/* ------------------------------------------------------------ trash */
.trash-note { color: var(--muted); font-size: 13px; margin: -20px 0 20px; }
.trash-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-card); padding: 14px; }
.trash-row .txt { flex: 1; min-width: 0; }
.trash-row b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-row .sub { color: var(--muted); font-size: 12.5px; }
.trash-row .sub .left { color: var(--red); font-weight: 500; }
.trash-row .sub .left.ok { color: var(--muted); }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 12px; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn-sm.green { background: var(--green-soft); color: var(--green-ink); }
.btn-sm.red { background: var(--red-soft); color: var(--red); width: 36px; padding: 0; justify-content: center; }

/* ------------------------------------------------------------ bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-radius: 26px 26px 0 0; box-shadow: 0 -6px 24px rgba(20,20,40,.06);
}
.nav-inner { max-width: 480px; margin: 0 auto; height: var(--nav-h); display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: center; }
.nav a { position: relative; display: grid; place-items: center; height: 56px; color: #8e8e93; text-decoration: none; border-radius: 16px; }
.nav a[aria-current="page"] { color: var(--green); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; bottom: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.fab {
  justify-self: center; width: 56px; height: 56px; border-radius: 50%; margin-top: -48px;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(47, 58, 78, .35); transition: transform .15s var(--ease);
}
.fab:active { transform: scale(.93); }

/* ------------------------------------------------------------ sheets & dialogs */
.backdrop { position: fixed; inset: 0; background: rgba(20, 22, 30, .38); z-index: 40; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; margin: 0 auto; max-width: 480px;
  max-height: 92vh; overflow: auto; background: var(--card); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(22px + var(--safe-b)); animation: sheet-up .28s var(--ease);
  box-shadow: 0 -10px 40px rgba(0,0,0,.12);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet.closing { transform: translateY(100%); transition: transform .2s ease-in; }
.backdrop.closing { opacity: 0; transition: opacity .2s; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: #e2e2e6; margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.sheet-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.close-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; color: var(--muted); flex: none; }

.field { margin-bottom: 16px; }
.field label, .field .label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .opt { color: var(--muted); font-weight: 400; }
.input {
  width: 100%; height: 50px; border-radius: 16px; border: 1.5px solid var(--line); background: #fafafb;
  padding: 0 14px; font-size: 16px; outline: none; transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--green); background: #fff; }
.input[aria-invalid="true"] { border-color: var(--red); background: #fff8f8; }
.err { color: var(--red); font-size: 12.5px; margin-top: 5px; display: flex; gap: 5px; align-items: center; }
.err:empty { display: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg label {
  margin: 0; display: grid; place-items: center; height: 44px; border-radius: 14px; background: var(--chip);
  color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; transition: background .15s, color .15s;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + label { background: var(--green); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; }
.prefix { position: relative; }
.prefix span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.prefix .input { padding-left: 28px; }
.stepper { display: flex; align-items: center; justify-content: space-between; height: 50px; border-radius: 16px; border: 1.5px solid var(--line); background: #fafafb; padding: 0 5px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); display: grid; place-items: center; color: var(--ink-2); }
.stepper button:disabled { opacity: .35; }
.stepper output, .stepper input { font-weight: 700; font-size: 17px; text-align: center; width: 48px; border: 0; background: none; outline: none; }
.img-preview { margin-top: 8px; height: 90px; border-radius: 14px; background: #f2f2f4; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 12.5px; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }

.btn {
  height: 52px; border-radius: 18px; padding: 0 22px; font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 8px 18px color-mix(in srgb, var(--green) 30%, transparent); }
.btn.dark { background: var(--navy); color: #fff; }
.btn.ghost { background: var(--chip); color: var(--ink-2); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-soft { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { flex: 1; }
.form-alert { background: var(--red-soft); color: var(--red); border-radius: 14px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.form-alert:empty { display: none; }

/* Quantity sheet */
.qty-big { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 6px 0 24px; }
.qty-big button { width: 60px; height: 60px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; color: var(--ink); }
.qty-big button:disabled { opacity: .35; }
.qty-big output { font-size: 44px; font-weight: 700; min-width: 80px; text-align: center; font-variant-numeric: tabular-nums; }
.qty-hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: -14px 0 18px; }

/* Persona assign sheet */
.assign-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.assign-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px;
  border-radius: 18px; background: #fafafb; border: 1.5px solid var(--line); transition: border-color .15s, background .15s;
}
.assign-opt[aria-checked="true"] { border-color: var(--green); background: var(--green-soft); }
.assign-opt .initial { width: 40px; height: 40px; font-size: 15px; background: #fff; }
.assign-opt .txt { flex: 1; min-width: 0; }
.assign-opt b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assign-opt .txt span { font-size: 12.5px; color: var(--muted); }
.tick { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted-2); display: grid; place-items: center; color: transparent; flex: none; }
.assign-opt[aria-checked="true"] .tick { background: var(--green); border-color: var(--green); color: #fff; }
.new-persona { display: flex; gap: 8px; }
.new-persona .input { flex: 1; }
.new-persona .btn { height: 50px; padding: 0 16px; }

/* Profile sheet */
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile .avatar-btn { width: 60px; height: 60px; }
.profile b { display: block; font-size: 18px; font-weight: 700; }
.profile span { color: var(--muted); font-size: 13px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border-radius: 16px; background: #fafafb; text-align: left; font-weight: 500; }
.menu button .ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.menu button.warn .ico { background: var(--red-soft); color: var(--red); }
.menu button .meta { margin-left: auto; color: var(--muted); font-size: 13px; }

.dialog-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.dialog-wrap .backdrop { z-index: 0; }
.dialog {
  position: relative; width: 100%; max-width: 340px; background: var(--card); border-radius: 26px;
  padding: 24px 20px 18px; text-align: center; animation: dialog-in .2s var(--ease); box-shadow: 0 20px 50px rgba(0,0,0,.18);
}
@keyframes dialog-in { from { opacity: 0; transform: scale(.95); } }
.dialog .ico { width: 54px; height: 54px; border-radius: 18px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.dialog p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.dialog .btn { height: 48px; font-size: 15px; }

/* Toasts */
#toast-layer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; } /* above the celebration layer (90); bottom clears the iPhone home indicator via --safe-b = env(safe-area-inset-bottom) */
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 448px; width: 100%;
  background: var(--navy); color: #fff; border-radius: 18px; padding: 12px 12px 12px 16px; font-size: 14px;
  box-shadow: 0 12px 30px rgba(20,20,40,.25); animation: toast-in .25s var(--ease);
}
.toast.error { background: #b4232a; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast .msg { flex: 1; min-width: 0; }
.toast button { color: #8ff08f; font-weight: 600; padding: 6px 10px; border-radius: 10px; }
.toast.error button { color: #fff; text-decoration: underline; }

@media (min-width: 560px) {
  .screen { padding-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.search .clear[hidden] { display: none; }
.input::-webkit-calendar-picker-indicator { display: none !important; }
body.has-sheet #toast-layer { top: calc(16px + env(safe-area-inset-top, 0px)); bottom: auto; }

/* ================= Kartifyit additions (Stage 1) ================= */
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; padding-bottom: 48px; }
.welcome h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.welcome h1 span { color: var(--green); }
.welcome > p { margin: 0; color: var(--muted); max-width: 300px; }
.welcome > .btn { width: 100%; max-width: 340px; }
.eyebrow { margin: 0; color: var(--green-ink); font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase; font-size: 12.5px; }
.logo-mark { width: 88px; height: 88px; margin: 0 auto; border-radius: 28px; background: var(--green-soft); display: grid; place-items: center; font-size: 46px; box-shadow: var(--shadow-card); }
.boot p { margin: 14px 0 0; }
.kart-card { width: 100%; max-width: 340px; background: var(--card); border-radius: 28px; box-shadow: var(--shadow-card); padding: 26px 20px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kart-pic { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; font-size: 46px; background: var(--green-soft); border: 4px solid #fff; box-shadow: var(--shadow-float); flex: none; }
.kart-name { margin-top: 10px; font-size: 24px; font-weight: 700; line-height: 1.2; }
.kart-tag { color: var(--muted); font-weight: 500; }
.roll-btn { margin-top: 14px; height: 46px; }
.roll-btn.rolling { animation: wiggle .45s var(--ease); }
@keyframes wiggle { 25% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-3deg); } }
.avatar-btn.kart-avatar { display: grid; place-items: center; background: var(--green-soft); font-size: 26px; }
.profile .kart-pic { width: 60px; height: 60px; font-size: 32px; border-width: 3px; }
.guest-badge { display: inline-block; margin-right: 4px; padding: 2px 10px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.profile + .note { margin: -6px 0 16px; }
.menu button .ico { font-size: 18px; }
.dept-tile { height: 58px; font-size: 14.5px; line-height: 1.2; }
.dept-tile[data-dept="produce"] { background: #eef8ea; }
.dept-tile[data-dept="bakery"] { background: #fff5e6; }
.dept-tile[data-dept="meat-seafood"] { background: #fdeeee; }
.dept-tile[data-dept="pantry"] { background: #f7f0e6; }
.dept-tile[data-dept="snacks"] { background: #fff8de; }
.dept-tile[data-dept="drinks"] { background: #e8f6fb; }
.dept-tile[data-dept="household"] { background: #f1f0fa; }
.dept-tile[data-dept="dairy-eggs"] { background: #eaf3fe; }
.dept-tile[data-dept="frozen"] { background: #e6f4f6; }
.dept-tile[data-dept="other"] { background: #f6f0fc; }
.close-btn { width: 44px; height: 44px; }
.welcome > .eyebrow { color: var(--green-ink); }

/* ================= Kartifyit additions (Stage 1, Plan 2a) ================= */
.screen.no-anim { animation: none; }
.cat { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dept-group { margin-bottom: 8px; }
.dept-head { display: flex; align-items: center; gap: 8px; margin: 26px 0 16px; font-size: 16px; font-weight: 700; }
.dept-head .n { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 500; }
.dept-grid { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dept-grid label {
  display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 64px; padding: 8px 2px;
  border-radius: 14px; background: var(--chip); color: var(--ink-2); font-size: 10.5px; font-weight: 600;
  line-height: 1.15; text-align: center; cursor: pointer;
}
.dept-grid label .emoji { font-size: 22px; line-height: 1; }
.dept-grid input { position: absolute; opacity: 0; pointer-events: none; }
.dept-grid input:checked + label { background: var(--green); color: #fff; }
.dept-grid input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; }
details.more { margin: 0 0 16px; }
details.more > summary { display: flex; align-items: center; min-height: 44px; color: var(--green-ink); font-weight: 600; font-size: 14px; cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
.size-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.stepper button { width: 44px; height: 44px; }
.toast button { min-height: 44px; }

/* Plan 2a touch targets: invisible hit-area extenders so every tappable thing reaches 44px, without changing how it looks */
.qty, .check, .heart, .link-btn, .hidden-note button { position: relative; }
.qty::after, .check::after, .heart::after, .card-fab::after, .link-btn::after, .hidden-note button::after { content: ""; position: absolute; }
.check::after, .heart::after, .link-btn::after, .hidden-note button::after { inset: -7px; }
.card-fab::after { inset: -6px; }
.qty::after { inset: -11px -4px; }
/* The name clips long text (overflow: hidden), which would clip a ::after, so it grows with padding and gives the space back with a negative margin. */
.name { position: relative; padding: 10.5px 0; margin: -7.5px 0; }
.qty { z-index: 1; } /* where a hit area overlaps the name's, the quantity button wins */

/* Plan 2a final fixes */
.search .clear { width: 44px; height: 44px; }
.sort-btn { position: relative; }
.sort-btn::after { content: ""; position: absolute; inset: -5px 0; }
.chip { min-height: 44px; }
.card-fab.x::after { top: -1px; }

/* ================= Kartifyit additions (Stage 1, Plan 2b) ================= */
.card-persona::after { content: ""; position: absolute; inset: -8px; }
.back-btn, .icon-chip { width: 44px; height: 44px; }
.btn-sm { min-height: 44px; }
.btn-sm.red { min-width: 44px; }

.order-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.order-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 6px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-card); }
.order-row.dragging { z-index: 5; box-shadow: var(--shadow-float); }
.order-row .emoji { font-size: 22px; line-height: 1; }
.order-row b { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.order-handle { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; }
.order-btns { display: flex; gap: 4px; }
.order-btns button { width: 44px; height: 44px; border-radius: 14px; background: var(--chip); color: var(--ink-2); display: grid; place-items: center; }
.order-btns [data-move="-1"] svg { transform: rotate(-90deg); }
.order-btns [data-move="1"] svg { transform: rotate(90deg); }
.order-btns button[aria-disabled="true"] { opacity: .35; }
.btn[aria-disabled="true"] { opacity: .6; cursor: default; }
@media (max-width: 420px) { .page-head:has(.head-actions) .head-tile { display: none; } }

/* ================= Kartifyit additions (Stage 1, Plan 3) ================= */
#fx-layer { position: fixed; inset: 0; z-index: 90; overflow: hidden; pointer-events: none; }
#fx-layer i { position: fixed; width: 9px; height: 14px; border-radius: 3px; animation: confetti-fly .8s ease-out forwards; }
@keyframes confetti-fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--turn)); opacity: 0; } }
.kartwheel { position: fixed; left: 50%; top: 38%; text-align: center; transform: translate(-50%, -50%); animation: kw-fade 2.1s ease forwards; }
.kw-emoji { display: block; font-size: 96px; line-height: 1; animation: kw-roll 1.5s ease-in-out; }
.kartwheel b { display: inline-block; margin-top: 8px; padding: 8px 18px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 16px; }
@keyframes kw-roll { from { transform: translateX(-140px) rotate(-720deg); } 65% { transform: translateX(0) rotate(0); } }
@keyframes kw-fade { 0% { opacity: 0; } 10%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  /* the badge just appears (feel.js removes it after a moment) instead of the fade ending at opacity 0 at once */
  .kartwheel { animation: none; opacity: 1; }
  .kw-emoji { animation: none; }
}

.start-shop { margin-bottom: 26px; height: 56px; font-size: 17px; }
.shop-bar { height: 8px; margin: -14px 0 18px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.shop-bar > i { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .3s var(--ease); }
.show-all { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.show-all input { position: relative; flex: none; width: 46px; height: 28px; margin: 0; border-radius: 999px; background: #d9d9de; appearance: none; cursor: pointer; transition: background .2s; }
.show-all input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-float); transition: transform .2s var(--ease); }
.show-all input:checked { background: var(--green); }
.show-all input:checked::after { transform: translateX(18px); }
.show-all input:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; }
.shop-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; padding: 12px 14px 12px 12px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow-card); transition: opacity .25s, transform .25s var(--ease); }
.shop-row.ticked { opacity: 0; transform: translateX(40px) scale(.97); }
.shop-tick { display: grid; flex: none; place-items: center; width: 56px; height: 56px; border: 3px solid #d9d9de; border-radius: 50%; background: #fff; color: transparent; transition: transform .15s var(--ease), background .15s, border-color .15s, color .15s; }
.shop-tick:active, .shop-row.ticked .shop-tick { transform: scale(1.1); border-color: var(--green); background: var(--green); color: #fff; }
.shop-main { flex: 1; min-width: 0; }
.shop-main b { display: block; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.shop-main span { color: var(--muted); font-size: 13px; }
.shop-price { min-width: 64px; min-height: 44px; padding: 0 12px; border-radius: 14px; background: var(--chip); font-size: 15px; font-weight: 700; }
.shop-price.corrected { background: var(--green-soft); color: var(--green-ink); }
.finish { height: 56px; margin: 22px 0 8px; font-size: 17px; }

.recap-preview { max-width: 300px; margin: 0 auto 20px; }
.recap-preview img { display: block; width: 100%; aspect-ratio: 9 / 16; border-radius: 24px; box-shadow: var(--shadow-card); }

/* ================= Kartifyit additions (Stage 1, Plan 4a) ================= */
.hist-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.hist-head .grow { flex: 1; min-width: 0; }
.hist-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.hist-head .sum { color: var(--muted); font-size: 13px; }
.hist-list { display: flex; flex-direction: column; gap: 10px; }
.hist-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-card); padding: 12px 12px 12px 14px; }
.hist-main { flex: 1 1 100px; min-width: 0; }
.hist-main b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.hist-main span { color: var(--muted); font-size: 12.5px; }
.hist-price { font-size: 15px; font-weight: 700; }
.btn-sm.listed { background: var(--chip); color: var(--muted); }
.hist-more { margin-top: 20px; }
.hist-delete { margin: 28px 0 8px; }
.legal { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.legal a { display: inline-block; padding: 14px 8px; color: var(--muted); text-decoration: underline; }
.doc { max-width: 640px; margin: 0 auto; padding: 24px 16px 60px; line-height: 1.55; }
.doc-back { display: inline-block; padding: 12px 0; color: var(--green-ink); font-weight: 600; text-decoration: none; }
.doc h1 { margin: 8px 0 8px; font-size: 28px; font-weight: 800; }
.doc h2 { margin: 28px 0 8px; font-size: 17px; font-weight: 700; }
.doc p, .doc li { color: var(--ink); font-size: 15px; }
.doc li { margin-bottom: 8px; }
.doc a { color: var(--green-ink); }
.doc-note { color: var(--muted); font-size: 13px; }

/* ================= Kartifyit additions (Stage 1, Plan 4b) ================= */
.save-banner { display: flex; align-items: center; gap: 12px; margin: 0 0 22px; padding: 14px 16px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow-card); }
.save-banner > div { flex: 1; min-width: 0; }
.save-banner b { display: block; font-size: 15px; }
.save-banner span { color: var(--muted); font-size: 13px; }
.save-banner .btn { flex: none; height: 44px; padding: 0 16px; }

#captcha-box { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 90; }

.btn.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; gap: 10px; display: flex; align-items: center; justify-content: center; }
.or-line { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: currentColor; opacity: .25; }

/* ------------------------------------------------------------ offline (Plan 5) */
.sync-note {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 34px; padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px;
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 600; text-align: center;
}
.sync-note[hidden] { display: none; }
.sync-note.sync { background: var(--blue); }
.sync-note.warn { background: #8a5a00; }
.sync-note.error { background: #b4232a; }
.sync-note button { min-height: 44px; margin: -6px 0; padding: 0 10px; color: #fff; font-weight: 700; text-decoration: underline; }
body.has-sync-note .screen { padding-top: calc(24px + 34px + env(safe-area-inset-top, 0px)); }
.review-list, .steps { margin: 0 0 16px; padding-left: 22px; line-height: 1.6; }
.review-list li, .steps li { margin-bottom: 6px; }
.review-list .meta { color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ================= Kartifyit additions (Stage 1, Plan 5: phone-test fixes) ================= */
.page-head h1 .store-btn { display: inline-block; margin: -10px 0; padding: 10px 0; text-align: left; font: inherit; color: inherit; letter-spacing: inherit; overflow-wrap: anywhere; }
.page-head h1 .store-btn span { color: var(--muted); font-size: .8em; }
.page-head h1 .store-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.menu .here { color: var(--muted); font-weight: 500; }
