/* ============================================================
   VisualShopr — style.css
   Design principles:
   · Warm orange + green palette — friendly, not clinical
   · Minimum 80px touch targets everywhere
   · No readable text on user-facing screens (except ARIA)
   · CSS custom properties so Caregiver Mode can override
   ============================================================ */

/* ── Reset + base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* Remove blue flash on tap */
}

:root {
  /* Palette */
  --c-orange:       #FF7A2F;
  --c-orange-dark:  #E05C10;
  --c-orange-light: #FFF0E6;
  --c-green:        #2EC486;
  --c-green-dark:   #22A370;
  --c-red:          #E74C3C;
  --c-gray:         #7A8FA6;
  --c-gray-light:   #F0F4F8;
  --c-bg:           #FFF8F2;
  --c-white:        #FFFFFF;
  --c-text:         #2D3A4A;

  /* Layout */
  --header-h:     68px;
  --bottombar-h:  104px;
  --fab-size:     84px;
  --grid-cols:    2;         /* overridden by JS via CSS var */
  --grid-gap:     10px;

  /* Shadows */
  --shadow-card:  0 3px 16px rgba(0,0,0,0.13);
  --shadow-btn:   0 6px 24px rgba(0,0,0,0.22);
  --shadow-fab:   0 8px 28px rgba(255,122,47,0.5);

  /* Animation */
  --trans-screen: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overflow: hidden;           /* Each screen manages its own scroll */
  background: var(--c-orange);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation; /* Prevent 300ms tap delay */
}

/* ── Screens ──────────────────────────────────────────────── */
/*
  All screens stack on top of each other at full viewport size.
  Only .active is visible; others are translated off-screen.
  Camera screen uses a right-to-left slide-in.
  Detail screen uses a scale-up from the tapped card.
*/
.screen {
  position: fixed;
  inset: 0;                   /* top/right/bottom/left = 0 */
  background: var(--c-bg);
  overflow: hidden;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--trans-screen),
    opacity   var(--trans-screen);
  will-change: transform;
}

.screen.active {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

/* Detail screen enters with a slight scale instead of slide */
#screen-detail {
  transform: scale(0.92);
}
#screen-detail.active {
  transform: scale(1);
}

/* Clerk screen slides in from the right (default) */
/* Already handled by the default .screen rule */


/* ── SCREEN 1 · HOME ──────────────────────────────────────── */

/* Header / logo bar */
#logo-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--c-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(255,122,47,0.25);
  /* Prevent text selection during the 3-second caregiver long-press */
  user-select: none;
  -webkit-user-select: none;
}

#logo {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
  /* Generous tap target */
  padding: 6px;
}

#logo:active { transform: scale(0.92); }
#logo svg, #logo img.header-logo-img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Hold-progress ring (absolutely positioned over the logo) */
#logo-hold-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#logo-hold-ring.visible { opacity: 1; }
#logo-hold-ring svg { width: 100%; height: 100%; }

/* ── Feature 1: Item counter ─────────────────────────────── */
/*
  Large friendly number in the header, right of centre.
  Hidden when the list is empty.
*/
.item-counter {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.22);
  border-radius: 20px;
  min-width: 44px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}

.item-counter.hidden { display: none; }

#item-counter-num {
  font-size: 1.45rem;
  font-weight: 800;
  color: white;
  line-height: 1;
  letter-spacing: -0.5px;
}

/* ── Feature 5: Clerk button ─────────────────────────────── */
.btn-clerk {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.12s;
  z-index: 15;
}

.btn-clerk:active {
  transform: translateY(-50%) scale(0.88);
  background: rgba(255,255,255,0.38);
}

.btn-clerk.hidden { display: none; }

/* ── Favourites shelf ────────────────────────────────────── */
/*
  Horizontal scrolling row of circular photo chips.
  Sits between the header and the items grid.
  Hidden (height: 0) when no favourites exist.
*/
#favourites-shelf {
  position: absolute;
  top: var(--header-h);
  left: 0; right: 0;
  height: 96px;
  background: var(--c-white);
  border-bottom: 2px solid #F0E8DF;
  display: flex;
  align-items: center;
  z-index: 5;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

#favourites-shelf.hidden { display: none; }

/* When shelf is visible, push the scroll wrapper (and empty state) down */
#favourites-shelf:not(.hidden) ~ #empty-state,
#favourites-shelf:not(.hidden) ~ #items-scroll {
  top: calc(var(--header-h) + 96px);
}

#favourites-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;      /* Firefox */
  height: 100%;
  width: 100%;
}
#favourites-row::-webkit-scrollbar { display: none; } /* Chrome/Safari */

/* Individual favourite chip */
.fav-chip {
  flex-shrink: 0;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 3px solid var(--c-orange-light);
  box-shadow: 0 3px 12px rgba(0,0,0,0.14);
  transition: transform 0.14s, box-shadow 0.14s;
}

.fav-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* "+" overlay — hints that tapping adds to list */
.fav-chip::after {
  content: "+";
  position: absolute;
  bottom: 0; right: 0;
  width: 24px; height: 24px;
  background: var(--c-orange);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  border: 2px solid white;
}

.fav-chip:active {
  transform: scale(0.88);
  box-shadow: 0 1px 6px rgba(0,0,0,0.12);
}

/* Brief "added" flash on the chip */
.fav-chip.just-added {
  border-color: var(--c-green);
  animation: chip-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chip-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* ── Empty state ─────────────────────────────────────────── */
#empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: var(--header-h);
  padding-bottom: var(--bottombar-h);
  /* Hidden when items exist */
}

#empty-state.hidden { display: none; }

.empty-illustration svg {
  width: min(220px, 55vw);
  height: auto;
}

/* Bouncing arrow pointing at the FAB (bottom-right) */
.empty-arrow {
  position: absolute;
  bottom: calc(var(--bottombar-h) + 38px);
  right: 112px;
  animation: bounce-right 1.2s ease-in-out infinite;
}
.empty-arrow svg {
  width: 54px;
  height: 36px;
}

@keyframes bounce-right {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(10px); }
}

/* ── Items scroll wrapper (fixed-height scroll container) ── */
#items-scroll {
  position: absolute;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: var(--bottombar-h);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Items grid (auto-height so rows size to content) ────── */
#items-grid {
  padding: var(--grid-gap);
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  gap: var(--grid-gap);
}

/* Individual item card */
.item-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  background: #e0d8d0;
  aspect-ratio: 1 / 1;
  /* align-self: start prevents the grid from stretching this item to fill
     a row that was sized by distributing the fixed container height.
     With start, the row sizes to the item's natural height (= column width
     via aspect-ratio), so squares are correct and dividers don't overlap. */
  align-self: start;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.25s;
  touch-action: pan-y;
  will-change: transform;
}

.item-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* Caregiver label overlay (only visible in debug/caregiver view) */
.item-label-overlay {
  display: none; /* Hidden from user — only shown in caregiver modal */
}

/* Feature 2: Quantity badge on card */
.qty-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--c-orange);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  letter-spacing: -0.5px;
  pointer-events: none;
}

/* Feature 6: Section divider between aisle groups */
.group-divider {
  grid-column: 1 / -1;   /* span every column */
  position: relative;
  height: 3px;
  border-radius: 2px;
  margin: 12px 2px;
  opacity: 0.75;
}

.group-divider-emoji {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  line-height: 1;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF8F2;
  border-radius: 50%;
  border: 2px solid var(--divider-color);
  box-shadow: 0 1px 5px rgba(0,0,0,0.18);
}

/* Feature 6: Aisle group colour border at bottom of card */
.item-card .group-border {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  pointer-events: none;
}

/* Pressed state */
.item-card:active { transform: scale(0.95); }

/* Swipe-left reveal — shows when swiping left to remove */
.item-card::after {
  content: "✕";
  position: absolute;
  inset: 0;
  background: var(--c-red);
  color: white;
  font-size: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  border-radius: 18px;
}

.item-card.swipe-removing::after { opacity: 0.85; }

/* Exit animation when item is removed */
.item-card.card-exit {
  transform: scale(0.6) translateY(-20px);
  opacity: 0;
}

/* ── Bottom bar ──────────────────────────────────────────── */
#bottom-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h);
  background: var(--c-white);
  border-top: 2px solid #F0E8DF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px); /* iPhone home bar */
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

/* Done Shopping button */
.btn-done {
  width: 82%;
  height: 72px;
  background: linear-gradient(135deg, #3D9AE8, #2C7EC4);
  border: none;
  border-radius: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(61,154,232,0.4);
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn-done svg { width: 54px; height: 54px; }

.btn-done:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(61,154,232,0.3);
}

/* ── FAB — Add item ─────────────────────────────────────── */
.btn-add {
  position: absolute;
  bottom: calc(var(--bottombar-h) + 16px);
  right: 18px;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: var(--c-orange);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  transition: transform 0.12s, box-shadow 0.12s;
  z-index: 20;
}

.btn-add svg {
  width: 54px;
  height: 54px;
}

.btn-add:active {
  transform: scale(0.92);
  box-shadow: 0 4px 14px rgba(255,122,47,0.4);
}

/* Pulse animation on the FAB when list is empty — draws attention */
.btn-add.pulse {
  animation: fab-pulse 2s ease-in-out infinite;
}

@keyframes fab-pulse {
  0%, 100% { box-shadow: var(--shadow-fab); }
  50%       { box-shadow: 0 0 0 16px rgba(255,122,47,0.15), var(--shadow-fab); }
}


/* ── SCREEN 2 · CAMERA ───────────────────────────────────── */

#screen-camera { background: #000; }

/* Live video preview fills the screen */
#video-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hidden off-screen canvas for snapping */
#snap-canvas {
  position: absolute;
  top: -9999px;
  left: -9999px;
  visibility: hidden;
}

/* Back arrow button */
.btn-back {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.12s;
}

.btn-back svg  { width: 32px; height: 32px; }
.btn-back:active { transform: scale(0.9); }

/* ── Square framing guide ────────────────────────────────── */
#camera-square-guide {
  position: absolute;
  /* Square centred vertically, full width */
  left: 0;
  right: 0;
  width: 100vw;
  height: 100vw;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  pointer-events: none;
  /* box-shadow darkens everything outside the square */
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.48);
}

/* White L-shaped corner markers */
.guide-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255,255,255,0.85);
  border-style: solid;
}
.guide-corner.tl { top: 0;    left: 0;  border-width: 3px 0 0 3px; }
.guide-corner.tr { top: 0;    right: 0; border-width: 3px 3px 0 0; }
.guide-corner.bl { bottom: 0; left: 0;  border-width: 0 0 3px 3px; }
.guide-corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; }

/* SNAP button — large shutter button at the bottom centre */
.btn-snap {
  position: absolute;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

/* Outer white ring */
.snap-outer-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.85);
  transition: transform 0.1s;
}

/* Inner white disc — shrinks on press to mimic real shutter */
.snap-inner-disc {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  transition: transform 0.12s;
}

.btn-snap:active .snap-inner-disc { transform: scale(0.82); }
.btn-snap:active .snap-outer-ring { transform: scale(1.08); }

/* ── Photo preview overlay (after snap) ─────────────────── */
#photo-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 40;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}

#photo-preview-overlay.hidden {
  display: none;
}

#preview-img {
  width: min(380px, 88vw);
  height: min(380px, 88vw);
  object-fit: cover;
  border-radius: 22px;
  border: 4px solid rgba(255,255,255,0.5);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.preview-actions {
  display: flex;
  gap: 32px;
  align-items: center;
}

.preview-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
}

.preview-btn:active { transform: scale(0.88); }
.preview-btn svg    { width: 90px; height: 90px; }

/* Green confirm button is bigger than the retake one */
.preview-btn-green {
  width: 110px;
  height: 110px;
}
.preview-btn-green svg { width: 110px; height: 110px; }


/* ── SCREEN 3 · ITEM DETAIL ──────────────────────────────── */

#screen-detail {
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#detail-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Feature 2: Quantity controls in detail screen */
#detail-quantity {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.55);
  border-radius: 40px;
  padding: 8px 18px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.qty-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 1.9rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.1s;
}

.qty-btn:active {
  background: rgba(255,255,255,0.35);
  transform: scale(0.88);
}

.qty-btn-plus  { background: rgba(46,196,134,0.4); }
.qty-btn-minus { background: rgba(231,76,60,0.35); }

.detail-qty-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: white;
  min-width: 40px;
  text-align: center;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Gradient fade at the bottom so buttons are legible over any photo */
#detail-actions {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 24px calc(28px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 100%);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  z-index: 10;
}

.detail-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}

.detail-btn svg    { width: 96px; height: 96px; }
.detail-btn:active { transform: scale(0.88); }

/* Green "bought it" button is bigger — it's the primary action */
.detail-btn-green svg { width: 112px; height: 112px; }


/* ── SCREEN 4 · CLERK SHARE ──────────────────────────────── */

#screen-clerk {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#clerk-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* contain so clerk sees the full item */
  background: #111;
  z-index: 0;
}

/* Dot indicators at top */
#clerk-dots {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
}

.clerk-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background 0.2s, transform 0.2s;
}

.clerk-dot.active {
  background: white;
  transform: scale(1.3);
}

/* Close button */
.clerk-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.4);
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform 0.12s;
}
.clerk-close-btn:active { transform: scale(0.88); }

/* "Got it!" bought button — bottom centre of clerk screen */
.clerk-bought-btn {
  position: absolute;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 20;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.5));
  transition: transform 0.12s;
}
.clerk-bought-btn svg    { width: 110px; height: 110px; }
.clerk-bought-btn:active { transform: translateX(-50%) scale(0.88); }

/* Visible nav arrows */
.clerk-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 0.12s, background 0.12s;
}

.clerk-arrow svg      { width: 36px; height: 36px; }
.clerk-arrow-prev     { left: 14px; }
.clerk-arrow-next     { right: 14px; }
.clerk-arrow:active   { background: rgba(255,255,255,0.25); transform: translateY(-50%) scale(0.9); }
.clerk-arrow.hidden   { display: none; }

/* Invisible tap zones: left half = prev, right half = next */
.clerk-tap-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  z-index: 10;
  cursor: pointer;
}

#clerk-tap-prev { left: 0; }
#clerk-tap-next { right: 0; }


/* ── FULLSCREEN OVERLAYS ──────────────────────────────────── */

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay.hidden { display: none; }

/* Done Shopping overlay — deep green background */
#overlay-done {
  background: var(--c-green);
  cursor: pointer; /* Whole screen is tappable to cancel */
}

.done-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.done-check-wrap svg {
  width: min(200px, 52vw);
  height: auto;
}

/* Path draws itself via stroke-dashoffset animation triggered by JS */
#done-check-path {
  transition: stroke-dashoffset 0.55s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}
#done-check-path.drawn { stroke-dashoffset: 0; }

/* Countdown cancel ring */
#done-cancel-ring {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cancel-x {
  font-size: 2.2rem;
  color: white;
  font-weight: 300;
  line-height: 1;
  /* sits inside the countdown ring */
  position: relative;
  z-index: 2;
}

/* Item removed overlay — brief green flash */
#overlay-removed {
  background: rgba(46, 196, 134, 0.9);
  pointer-events: none;
}

.removed-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.removed-checkmark {
  font-size: 7rem;
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pop-in {
  0%   { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}


/* ── Feature 3: Shake-undo toast ────────────────────────── */
.toast-undo {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--c-green);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  padding: 18px 24px calc(18px + env(safe-area-inset-top, 0px));
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast-undo.visible {
  transform: translateY(0);
}

.toast-undo.hidden { display: none; }


/* ── Feature 4: Confetti canvas ─────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  width: 100%;
  height: 100%;
}


/* ── CAREGIVER MODAL ─────────────────────────────────────── */
/*
  Full-screen modal with a semi-transparent backdrop.
  Scrollable inner panel — designed for a sighted caregiver, not the main user.
*/

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end; /* Sheet slides up from bottom */
}

.modal.hidden { display: none; }

/* Dark translucent backdrop */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  cursor: pointer; /* Tap backdrop to close */
}

/* White sheet */
.modal-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 92vh;
  background: var(--c-white);
  border-radius: 24px 24px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px 40px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
  animation: sheet-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--c-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 14px;
  border-bottom: 1px solid #EEE;
  z-index: 2;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-text);
  flex: 1;
}

.cg-lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--c-gray-light);
  border-radius: 8px;
  padding: 3px;
  margin-right: 10px;
}

.cg-lang-btn {
  padding: 4px 11px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--c-gray);
  transition: background 0.15s, color 0.15s;
}

.cg-lang-btn.active {
  background: white;
  color: var(--c-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.cg-close-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--c-gray-light);
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text);
}

.cg-section {
  padding: 18px 0;
  border-bottom: 1px solid #F0F0F0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cg-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
}

.cg-note {
  font-size: 0.85rem;
  color: #888;
  line-height: 1.4;
}

/* Toggle row */
.cg-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--c-text);
  cursor: pointer;
  min-height: 44px;
}

.cg-toggle-wrap {
  position: relative;
  display: inline-flex;
}

.cg-toggle-wrap input[type="checkbox"] {
  opacity: 0;
  width: 0; height: 0;
  position: absolute;
}

.cg-toggle-track {
  width: 52px;
  height: 30px;
  background: #CCC;
  border-radius: 15px;
  transition: background 0.25s;
  cursor: pointer;
}

.cg-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.25s;
}

.cg-toggle-wrap input:checked + .cg-toggle-track {
  background: var(--c-green);
}
.cg-toggle-wrap input:checked + .cg-toggle-track::after {
  transform: translateX(22px);
}

/* Label row */
.cg-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--c-text);
  min-height: 44px;
}

.cg-select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #DDD;
  font-size: 0.95rem;
  background: var(--c-gray-light);
  color: var(--c-text);
  cursor: pointer;
  min-width: 160px;
}

/* Action buttons */
.cg-btn {
  padding: 13px 18px;
  border-radius: 14px;
  border: none;
  background: var(--c-gray-light);
  color: var(--c-text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  min-height: 52px;
  transition: background 0.15s;
}

.cg-btn:active { background: #E0E8F0; }

.cg-btn-danger {
  background: #FEE;
  color: var(--c-red);
}
.cg-btn-danger:active { background: #FDD; }

/* Item label edit rows */
.cg-label-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #F5F5F5;
}

.cg-label-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.cg-label-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #DDD;
  font-size: 0.9rem;
  background: var(--c-gray-light);
  color: var(--c-text);
  min-height: 44px;
}

.cg-label-input:focus {
  outline: 2px solid var(--c-orange);
  border-color: transparent;
}

/* Feature 6: Aisle group colour swatches in caregiver */
.cg-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.cg-group-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  position: relative;
  flex-shrink: 0;
}

.cg-group-swatch.none-swatch {
  background: #E0E0E0;
  border: 3px solid #CCC;
}

.cg-group-swatch:active { transform: scale(0.85); }

.cg-group-swatch.selected {
  border-color: var(--c-text) !important;
  transform: scale(1.18);
}

/* Saved favourite row in caregiver modal */
.cg-fav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #F5F5F5;
}

.cg-fav-thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--c-orange-light);
}

.cg-fav-label {
  flex: 1;
  font-size: 0.9rem;
  color: var(--c-text);
}

/* ── Emoji group pickers ─────────────────────────────────── */

/* Per-item aisle picker (category emojis: 🥩🥦🥛 etc.) */
.cg-group-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0 4px;
}

.cg-group-emoji-btn {
  font-size: 1.5rem;
  background: none;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 4px 6px;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.12s, border-color 0.12s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cg-group-emoji-btn.selected {
  border-color: var(--c-orange);
  background: var(--c-orange-light);
}

.cg-group-emoji-btn:active { transform: scale(0.88); }

/* Section order ↑↓ buttons */
.cg-order-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.cg-order-btn {
  width: 28px;
  height: 24px;
  font-size: 0.85rem;
  line-height: 1;
  background: var(--c-gray-light);
  border: 1px solid #D8DFE8;
  border-radius: 5px;
  cursor: pointer;
  color: var(--c-text);
  transition: background 0.15s;
}

.cg-order-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.cg-order-btn:not(:disabled):active {
  background: var(--c-orange-light);
  border-color: var(--c-orange);
}

/* Section tile grid */
.cg-section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cg-section-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  background: #F5F5F5;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.cg-section-tile.active {
  opacity: 1;
  border-color: var(--tile-color, #ccc);
  background: color-mix(in srgb, var(--tile-color, #ccc) 15%, white);
}

.cg-section-tile-emoji {
  font-size: 26px;
  line-height: 1;
}

.cg-section-tile-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text);
  text-align: center;
  line-height: 1.2;
}

/* Per-group colour picker (circle emojis: 🔴🟠🟡 etc.) */
.cg-group-colour-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #F5F5F5;
  flex-wrap: wrap;
}

.cg-group-colour-label {
  font-size: 1rem;
  min-width: 110px;
  color: var(--c-text);
}

.cg-emoji-colour-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 4px 0 6px;
}

.cg-colour-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}

.cg-colour-dot.selected {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px white, 0 0 0 4px currentColor, 0 2px 6px rgba(0,0,0,0.25);
}

.cg-colour-dot:active { transform: scale(0.9); }

.cg-fav-remove {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: #FEE;
  color: var(--c-red);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Feature 7: Templates section */
.cg-template-save-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cg-template-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #F5F5F5;
}

.cg-template-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--c-text);
}

.cg-template-meta {
  font-size: 0.78rem;
  color: #AAA;
}

.cg-template-load {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: var(--c-orange-light);
  color: var(--c-orange-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  min-height: 40px;
}

.cg-template-load:active { background: #FFDFC0; }

.cg-template-delete {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: #FEE;
  color: var(--c-red);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cg-footer {
  text-align: center;
  font-size: 0.78rem;
  color: #BBB;
  padding-top: 20px;
}


/* ── iOS Install Prompt ──────────────────────────────────── */

.ios-install-backdrop {
  background: rgba(0,0,0,0.45);
}

.ios-install-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 88vh;
  background: var(--c-white);
  border-radius: 24px 24px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 22px calc(32px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
  animation: sheet-up 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.ios-install-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 14px;
  border-bottom: 1px solid #EEE;
  position: sticky;
  top: 0;
  background: var(--c-white);
  z-index: 2;
}

.ios-install-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-text);
}

.ios-install-intro {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.5;
  padding: 16px 0 8px;
}

.ios-install-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 0 16px;
}

.ios-install-step {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
  color: var(--c-text);
  line-height: 1.45;
}

.ios-step-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.ios-step-icon svg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.ios-install-hint {
  font-size: 0.82rem;
  color: #999;
  line-height: 1.45;
  padding-bottom: 20px;
  border-bottom: 1px solid #F0F0F0;
  margin-bottom: 20px;
}

.ios-install-got-it-btn {
  width: 100%;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: var(--c-orange);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,122,47,0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}

.ios-install-got-it-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(255,122,47,0.25);
}


/* ── Utility ─────────────────────────────────────────────── */

.hidden { display: none !important; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Focus ring for keyboard/AT users — hidden when using touch */
:focus-visible {
  outline: 3px solid var(--c-orange);
  outline-offset: 3px;
}


/* ── Responsive tweaks ───────────────────────────────────── */

/* Tablets: bump up button sizes slightly */
@media (min-width: 600px) {
  :root {
    --fab-size:    96px;
    --bottombar-h: 112px;
    --grid-gap:    14px;
  }
  .btn-done { height: 80px; }
  .detail-btn svg         { width: 110px; height: 110px; }
  .detail-btn-green svg   { width: 128px; height: 128px; }
}

/* Large tablets: allow 3-column layout by default */
@media (min-width: 900px) {
  :root { --grid-cols: 3; }
}

/* Notched phones: push FAB up a bit more */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .btn-add {
    bottom: calc(var(--bottombar-h) + 16px + env(safe-area-inset-bottom, 0px));
  }
}


/* ─── Generic dialog (alert/confirm replacement) ─────────── */
.app-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(420px, 92vw);
  width: 92vw;
  background: #fff;
  color: #2a1f17;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.app-dialog::backdrop {
  background: rgba(0,0,0,0.45);
}
.app-dialog-form {
  margin: 0;
  padding: 24px;
}
.app-dialog-message {
  font-family: sans-serif;
  font-size: 17px;
  line-height: 1.45;
  margin: 0 0 20px 0;
  color: #2a1f17;
}
.app-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.app-dialog-btn {
  font-family: sans-serif;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  min-width: 88px;
}
.app-dialog-btn-cancel {
  background: #eee;
  color: #444;
}
.app-dialog-btn-ok {
  background: #FF7A2F;
  color: #fff;
}
.app-dialog-btn-cancel.hidden { display: none; }


/* ─── Landing / first-visit explainer ─────────────────────── */
#screen-landing {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #fff8f2 0%, #ffead6 100%);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: max(24px, env(safe-area-inset-top, 0px)) 20px max(24px, env(safe-area-inset-bottom, 0px));
}
#screen-landing.hidden {
  display: none;
}
.landing-inner {
  max-width: 460px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 12px;
}
.landing-langbar {
  align-self: flex-end;
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}
.landing-lang {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1.5px solid #FF7A2F;
  background: transparent;
  color: #FF7A2F;
  border-radius: 999px;
  cursor: pointer;
}
.landing-lang.active {
  background: #FF7A2F;
  color: #fff;
}
.landing-logo {
  width: 96px;
  height: 96px;
  margin-bottom: 14px;
  filter: drop-shadow(0 4px 12px rgba(255, 122, 47, 0.25));
}
.landing-title {
  font-size: 36px;
  font-weight: 800;
  color: #FF7A2F;
  margin: 0 0 4px 0;
  letter-spacing: -0.5px;
}
.landing-tag {
  font-size: 17px;
  color: #6b5b50;
  margin: 0 0 28px 0;
}
.landing-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.landing-steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.landing-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FF7A2F;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.landing-step-text {
  font-size: 15.5px;
  line-height: 1.35;
  color: #2a1f17;
}
.landing-builtfor {
  font-size: 14px;
  line-height: 1.5;
  color: #6b5b50;
  margin: 0 0 24px 0;
  padding: 0 4px;
}
.landing-start {
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: #FF7A2F;
  border: none;
  border-radius: 14px;
  padding: 16px 32px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(255, 122, 47, 0.4);
  min-width: 200px;
  justify-content: center;
}
.landing-start:active {
  transform: scale(0.98);
}
.landing-start-arrow {
  font-size: 22px;
  line-height: 1;
}
.landing-fineprint {
  font-size: 12.5px;
  color: #8a7a6e;
  margin: 18px 0 0 0;
}

.landing-contact {
  font-size: 12.5px;
  color: #8a7a6e;
  margin: 4px 0 0 0;
}
.landing-contact a {
  color: #FF7A2F;
  text-decoration: none;
}
