:root {
  --bg: #FFF6E0;
  --card: #FFFFFF;
  --ink: #2E2347;
  --muted: #8A7FA3;
  --faint: #C9C0D9;
  --line: #F1E8DA;
  --soft: #FFF1F7;
  --pink: #FF5FA2;
  --purple: #8A5CF6;
  --orange: #FF9F1C;
  --green: #22C08A;
  --blue: #4D9BFF;
  --yellow: #FFD23F;
  --danger: #E8336D;
  --store: #FF5FA2;
  --shadow: 0 3px 0 rgba(46, 35, 71, .06), 0 10px 24px rgba(120, 80, 60, .10);
  --r: 22px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  /* a quiet sprinkle of colored dots, like a party tablecloth */
  background-image:
    radial-gradient(circle at 12px 12px, rgba(255, 95, 162, .16) 4px, transparent 5px),
    radial-gradient(circle at 52px 40px, rgba(77, 155, 255, .14) 3px, transparent 4px),
    radial-gradient(circle at 30px 70px, rgba(34, 192, 138, .14) 3.5px, transparent 4.5px),
    radial-gradient(circle at 74px 8px, rgba(255, 210, 63, .28) 3px, transparent 4px);
  background-size: 88px 88px;
  color: var(--ink);
  font-family: 'Fredoka', 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(120px + env(safe-area-inset-bottom)); }
.loading { display: grid; place-items: center; min-height: 80vh; }
.cart-bounce { font-size: 64px; animation: bounce 0.9s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-18px) rotate(6deg); } }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.logo { width: 54px; height: 54px; flex: none; border-radius: 17px; box-shadow: 0 4px 0 rgba(200, 60, 110, .25); transform: rotate(-4deg); }
.brand { flex: 1; min-width: 0; }
.brand small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: .2px; }
.brand h1 { margin: 0; font-size: 25px; font-weight: 700; line-height: 1.1; }
.brand h1 .fam {
  background: linear-gradient(90deg, var(--pink), var(--orange) 45%, var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.me-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: #fff; box-shadow: var(--shadow); border: 3px solid var(--me, var(--pink)); }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: #fff; box-shadow: var(--shadow); }

/* ---------- the add box ---------- */
.add {
  background: #fff; border-radius: 26px; padding: 14px; box-shadow: var(--shadow);
  border: 3px solid transparent;
  background-image: linear-gradient(#fff, #fff), linear-gradient(120deg, var(--pink), var(--orange), var(--yellow), var(--green), var(--blue), var(--purple));
  background-origin: border-box; background-clip: padding-box, border-box;
  margin-top: 6px;
}
.add label { display: block; font-weight: 600; font-size: 18px; margin: 2px 4px 8px; }
.add textarea {
  width: 100%; min-height: 76px; resize: none; border: 0; outline: 0; background: #FFF9EE;
  border-radius: 16px; padding: 12px 14px; font-size: 18px; line-height: 1.45; font-family: 'Rubik', 'Fredoka', sans-serif;
}
.add textarea::placeholder { color: #B9AEC9; }
.add-row { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.mic {
  width: 58px; height: 58px; flex: none; border-radius: 50%; font-size: 26px; display: grid; place-items: center;
  background: var(--purple); color: #fff; box-shadow: 0 4px 0 #6238D6;
}
.mic.on { background: var(--danger); box-shadow: 0 4px 0 #B01E50; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.go {
  flex: 1; height: 58px; border-radius: 18px; font-size: 20px; font-weight: 700; color: #fff;
  background: linear-gradient(90deg, var(--pink), var(--orange)); box-shadow: 0 4px 0 #D9467F;
}
.go:active, .mic:active, .btn:active { transform: translateY(3px); box-shadow: none; }
.go[disabled] { opacity: .65; }
.hint { font-size: 14px; color: var(--muted); margin: 8px 6px 0; }
.thinking { display: inline-flex; gap: 5px; vertical-align: middle; }
.thinking i { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: hop .9s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes hop { 0%, 100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(-6px); opacity: 1; } }

/* ---------- store tabs ---------- */
.stores { display: flex; gap: 10px; margin: 18px -16px 6px; padding: 4px 16px 8px; overflow-x: auto; scrollbar-width: none; }
.stores::-webkit-scrollbar { display: none; }
.store-tab {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 16px 10px 12px; border-radius: 999px;
  background: #fff; font-weight: 600; font-size: 17px; box-shadow: var(--shadow); border: 3px solid transparent; white-space: nowrap;
}
.store-tab .em { font-size: 24px; line-height: 1; }
.store-tab .n { min-width: 26px; height: 26px; border-radius: 13px; padding: 0 7px; display: grid; place-items: center; font-size: 14px; color: #fff; background: var(--c); }
.store-tab .n.zero { background: #EFE9F5; color: var(--muted); }
.store-tab.on { background: var(--c); color: #fff; border-color: rgba(255, 255, 255, .6); box-shadow: 0 4px 0 rgba(0, 0, 0, .14); }
.store-tab.on .n { background: #fff; color: var(--c); }
.store-tab.pop { animation: pop .5s ease; }
@keyframes pop { 40% { transform: scale(1.12) rotate(-3deg); } }

/* ---------- the list ---------- */
.cat { margin-top: 16px; }
.cat-head { display: flex; align-items: center; gap: 8px; margin: 0 6px 8px; font-weight: 600; font-size: 18px; }
.cat-head .em { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; background: #fff; box-shadow: var(--shadow); }
.cat-head .cnt { color: var(--muted); font-weight: 500; font-size: 15px; }
.cat-head .plus { margin-inline-start: auto; width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); color: var(--store); font-size: 22px; font-weight: 700; line-height: 1; }
.cat.unsorted .cat-head { color: var(--danger); }
.items { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 18px; padding: 10px 10px 10px 8px;
  box-shadow: var(--shadow); min-height: 62px; position: relative; overflow: hidden;
}
.item .tap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: start; padding: 2px 4px; }
.check {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 3px solid var(--store); display: grid; place-items: center;
  color: #fff; font-size: 18px; font-weight: 700; transition: background .2s, transform .2s;
}
.item .name { font-size: 19px; font-weight: 500; overflow-wrap: anywhere; font-family: 'Rubik', 'Fredoka', sans-serif; }
.qty { flex: none; font-weight: 700; font-size: 15px; padding: 4px 10px; border-radius: 999px; background: #FFF1D6; color: #B66A00; white-space: nowrap; }
.who { flex: none; font-size: 18px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #F7F3FC; }
.thumb { flex: none; width: 46px; height: 46px; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0,0,0,.15); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item.bought .thumb { opacity: .55; }
.photo-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-btns .btn { flex: 1; height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; min-width: 130px; }
.photo-edit { display: flex; gap: 12px; align-items: center; }
.photo-edit img { width: 110px; height: 110px; object-fit: cover; border-radius: 18px; box-shadow: var(--shadow); flex: none; }
.photo-edit .photo-btns { flex-direction: column; flex: 1; }
.photo-edit .photo-btns .btn { flex: none; }
.photo-big { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.top-save { height: 44px; font-size: 16px; padding: 0 16px; }
.edit { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; background: #F7F3FC; }
.item.fresh { animation: slide-in .5s ease; box-shadow: 0 0 0 3px var(--yellow), var(--shadow); }
@keyframes slide-in { from { transform: translateY(-10px) scale(.96); opacity: 0; } }
.item.bought { background: rgba(255, 255, 255, .62); box-shadow: none; }
.item.bought .check { background: var(--green); border-color: var(--green); transform: rotate(-8deg); }
.item.bought .name { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.item.bought .qty { background: #EFEBF4; color: var(--muted); }
.item.just-bought .check { animation: boing .45s ease; }
@keyframes boing { 30% { transform: scale(1.35) rotate(-14deg); } 60% { transform: scale(.9); } }

.basket { margin-top: 26px; padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, .5); border: 3px dashed #E9DCCB; }
.basket h3 { margin: 0 6px 10px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.basket h3 .cnt { color: var(--muted); font-weight: 500; font-size: 15px; }
.done-btn {
  width: 100%; margin-top: 12px; height: 56px; border-radius: 18px; font-weight: 700; font-size: 18px;
  background: var(--green); color: #fff; box-shadow: 0 4px 0 #17936A;
}

.empty { text-align: center; padding: 34px 20px 10px; }
.empty .big { font-size: 76px; line-height: 1; display: inline-block; animation: bounce 2.4s ease-in-out infinite; }
.empty h2 { margin: 12px 0 4px; font-size: 24px; }
.empty p { margin: 0; color: var(--muted); }

.again { margin-top: 26px; }
.again h3 { margin: 0 6px 10px; font-size: 17px; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-size: 16px; font-family: 'Rubik', 'Fredoka', sans-serif; }
.chip b { color: var(--store); margin-inline-end: 4px; }

/* ---------- sheets ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(46, 35, 71, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--bg); border-radius: 30px 30px 0 0;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes up { from { transform: translateY(100%); } }
@media (min-width: 700px) { .sheet-back { align-items: center; } .sheet { border-radius: 30px; } }
.grab { width: 48px; height: 6px; border-radius: 3px; background: #E3D8C8; margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 23px; }
.close { width: 42px; height: 42px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 18px; }
.field { margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin: 0 4px 6px; }
.input { width: 100%; height: 52px; border-radius: 16px; border: 3px solid #EFE4D4; background: #fff; padding: 0 14px; font-size: 18px; outline: 0; font-family: 'Rubik', 'Fredoka', sans-serif; }
.input:focus { border-color: var(--purple); }
textarea.input { height: auto; min-height: 70px; padding: 10px 14px; resize: vertical; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 52px; height: 52px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); font-size: 26px; font-weight: 700; color: var(--purple); }
.stepper .input { width: 92px; text-align: center; font-weight: 700; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { padding: 8px 13px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-size: 15px; border: 2px solid transparent; }
.pick button.on { background: var(--purple); color: #fff; }
.store-group { margin-bottom: 12px; }
.store-group .sg-name { font-weight: 600; margin: 0 4px 6px; color: var(--sc); }
.btn { height: 54px; padding: 0 18px; border-radius: 17px; font-weight: 700; font-size: 18px; background: #fff; box-shadow: var(--shadow); }
.btn.primary { background: var(--purple); color: #fff; box-shadow: 0 4px 0 #6238D6; }
.btn.danger { color: var(--danger); }
.btn.sure { background: var(--danger); color: #fff; box-shadow: 0 4px 0 #B01E50; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn.primary { flex: 1; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; padding: 4px 0 10px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 22px; background: #fff; box-shadow: var(--shadow); font-weight: 600; font-size: 19px; border: 3px solid var(--c); }
.person .face { font-size: 46px; line-height: 1; }

.tabs { display: flex; gap: 6px; background: #fff; padding: 5px; border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.tabs button { flex: 1; height: 42px; border-radius: 14px; font-weight: 600; font-size: 15px; }
.tabs button.on { background: var(--purple); color: #fff; }
.set-store { background: #fff; border-radius: 22px; box-shadow: var(--shadow); padding: 12px; margin-bottom: 14px; border-top: 6px solid var(--sc); }
.set-row { display: flex; align-items: center; gap: 6px; padding: 6px 2px; border-bottom: 2px dashed var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .em-in { width: 48px; flex: none; text-align: center; font-size: 20px; padding: 0; }
.set-row .input { height: 44px; font-size: 16px; }
.mini { width: 36px; height: 36px; flex: none; border-radius: 11px; background: #F7F3FC; font-size: 15px; display: grid; place-items: center; }
.mini.red { color: var(--danger); background: #FFE8EF; }
.mini.sure { background: var(--danger); color: #fff; width: auto; padding: 0 8px; font-size: 13px; }
.add-line { display: flex; gap: 6px; margin-top: 8px; }
.add-line .input { height: 44px; font-size: 16px; }
.add-line .em-in { width: 54px; flex: none; text-align: center; padding: 0; }
.add-line .btn { height: 44px; font-size: 15px; padding: 0 14px; }
.note { background: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 15px; margin-bottom: 12px; }
.note.bad { background: #FFE8EF; color: #8C1640; }
.note.good { background: #E2F8EF; color: #0E6B4B; }
.steps { padding-inline-start: 22px; margin: 6px 0 14px; }
.steps li { margin-bottom: 8px; }
.small { font-size: 14px; color: var(--muted); }

/* ---------- toast + confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 160%);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 18px; z-index: 60; width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 12px; font-size: 16px; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
  box-shadow: 0 10px 30px rgba(46, 35, 71, .35);
}
.toast.show { transform: translate(-50%, 0); }
.toast.warn { background: #B4235A; }
.toast button { color: var(--yellow); font-weight: 700; padding: 4px 6px; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100vw; height: 100vh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
