/* Kitchen counter. A soft green food photo under frosted paper, produce washes, two loud numbers,
   quiet until touched. Ink is espresso only. Saffron is a fill, never text. Steam is decoration only. */

:root {
  --paper: #f3e6d4;
  --cream: #fff8ee;
  --ink: #3b2415;
  --ink-soft: #6b5242;
  --steam: #8a6a52;
  --herb: #2f6b45;
  --herb-wash: #dfe9d6;
  --tomato: #c4482d;
  --tomato-deep: #a63a22;
  --tomato-wash: #f5d9cc;
  --saffron: #e09a2b;
  --saffron-wash: #f4dcab;
  --on-fill: #fffaf2;
  --edge: rgba(59, 36, 21, 0.08);
  --edge-strong: rgba(59, 36, 21, 0.22);
  --highlight: #fffdf8;
  /* frosted paper */
  --glass: rgba(255, 248, 238, 0.68);
  --glass-strong: rgba(255, 248, 238, 0.86);
  --glass-edge: rgba(255, 255, 255, 0.62);
  --glass-blur: blur(16px) saturate(1.35);
  --lift: 0 12px 26px -16px rgba(59, 36, 21, 0.5);
  --radius: 1.05rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 80ms;
  --t-dock: 220ms;
  --t-morph: 180ms;
  --t-wheel: 160ms;
  --t-tick: 200ms;
  --t-wash: 240ms;
  --mark-size: 32px;
  --qty-width: 3.4rem;
  --row-h: 2.75rem;
  --page-pad: 0.85rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/rubik-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}
@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/rubik-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+20AC;
}
@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/rubik-hebrew-500.woff2") format("woff2");
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: Rubik;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/rubik-hebrew-700.woff2") format("woff2");
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

html, body { margin: 0; min-height: 100%; }
html {
  scroll-padding-top: 8.5rem;
  scroll-padding-bottom: 7rem;
  /* no blue flash on tap: presses are shown by the card sinking into the paper instead */
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: Rubik, "Segoe UI", "Arial Hebrew", "Helvetica Neue", sans-serif;
  font-weight: 500;
  color: var(--ink);
  background-color: var(--paper);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
::selection { background: rgba(47, 107, 69, 0.22); color: inherit; }

/* The photo sits far back and faint; paper wash and grain sit on top of it. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: url("/images/green-counter.jpg") center / cover no-repeat;
  opacity: 0.58;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    url("/textures/fiber.svg"),
    url("/textures/paper.svg"),
    linear-gradient(180deg, rgba(243, 230, 212, 0.28), rgba(243, 230, 212, 0.62));
  background-size: 400px 400px, 180px 180px, 100% 100%;
}

h1, h2, h3, strong { font-weight: 700; }

button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--herb);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  inset-inline-start: 0.5rem;
  top: -3.5rem;
  background: var(--ink);
  color: var(--on-fill);
  padding: 0.6rem 0.9rem;
  border-radius: 0.7rem;
  z-index: 30;
}
.skip:focus { top: 0.5rem; }

/* One quiet fade for the language swap. Never the whole body. */
.shell { transition: opacity 160ms var(--ease); }
.shell.is-locale-out { opacity: 0.85; }

.shell {
  width: min(42rem, 100%);
  margin: 0 auto;
  padding: 0 var(--page-pad) calc(6.75rem + env(safe-area-inset-bottom));
}

.icon { width: 1.35rem; height: 1.35rem; display: inline-flex; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ---------- frosted paper ---------- */

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), var(--lift);
}

/* ---------- buttons ---------- */

button {
  transition:
    transform var(--t-press) var(--ease),
    box-shadow 160ms var(--ease),
    background-color 160ms var(--ease),
    filter 160ms var(--ease);
}
/* press: the card sinks 1px and a soft shadow pools inside, like a thumb on paper */
button:active:not(:disabled) { transform: translateY(1px); }
.lang-cycle:active, .icon-btn:active, .ghost-btn:active, .dock-btn:active, .unit-pill:active,
.price-chip:active, .stepper-btn:active, .icon-chip:active, .icon-tile:active, .suggest-row:active {
  box-shadow: inset 0 2px 6px rgba(59, 36, 21, 0.22);
}
.primary-btn:active:not(:disabled), .danger-btn:active:not(:disabled), .fab:active, .wheel-confirm:active, .finish-btn:active {
  filter: brightness(0.92);
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.28);
}

.lang-cycle {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  box-shadow: inset 0 1px 0 var(--highlight), 0 6px 14px -10px rgba(59, 36, 21, 0.5);
  border-radius: 999px;
  padding: 0 0.9rem;
  font-weight: 700;
}

.primary-btn, .ghost-btn, .danger-btn {
  min-height: 48px;
  border-radius: 999px;
  border: 0;
  padding: 0.65rem 1.2rem;
  font-weight: 700;
}
.primary-btn { background: var(--herb); color: var(--on-fill); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.ghost-btn { background: var(--glass-strong); border: 1px solid var(--edge-strong); box-shadow: inset 0 1px 0 var(--highlight); }
.danger-btn { background: var(--tomato); color: var(--on-fill); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.primary-btn:disabled, .ghost-btn:disabled, .danger-btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--glass-edge);
  border-radius: 0.95rem;
  background: var(--glass-strong);
  box-shadow: inset 0 1px 0 var(--highlight), 0 6px 14px -10px rgba(59, 36, 21, 0.5);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:disabled { opacity: 0.5; cursor: default; }

.form-error { color: var(--tomato-deep); min-height: 1.2rem; margin: 0; font-size: 0.92rem; }

/* ---------- landing ---------- */

.landing {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  text-align: center;
  padding-top: calc(1.5rem + env(safe-area-inset-top));
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  overflow-x: clip;
}
.landing .lang-cycle {
  position: absolute;
  inset-block-start: calc(0.75rem + env(safe-area-inset-top));
  inset-inline-end: var(--page-pad);
  z-index: 3;
}
.hero {
  position: relative;
  isolation: isolate;
  z-index: 1;
  width: min(24rem, 100%);
  aspect-ratio: 360 / 220;
  display: grid;
  place-items: center;
  overflow: clip;
}
.still-life {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  animation: still-drift 10s ease-in-out infinite alternate;
}
.hero h1 {
  position: relative;
  margin: 0;
  padding-inline: 1rem;
  font-size: clamp(2.2rem, 11vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.create-btn {
  position: relative;
  z-index: 2;
  width: min(20rem, 100%);
  min-height: 56px;
  font-size: 1.1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 12px 22px -14px rgba(47, 107, 69, 0.9);
}
.landing .form-error { position: relative; z-index: 2; }

/* ---------- sticky header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: calc(0.35rem + env(safe-area-inset-top));
  padding-bottom: 0.15rem;
  margin-inline: calc(var(--page-pad) * -1);
  padding-inline: var(--page-pad);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-edge);
  box-shadow: 0 10px 22px -18px rgba(59, 36, 21, 0.6);
}
.title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}
.list-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tools { display: flex; gap: 0.35rem; align-items: center; }

.search-form { position: relative; margin-top: 0.3rem; }
.search-wrap { position: relative; }
.search-wrap .search-icon {
  position: absolute;
  inset-inline-start: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
#search {
  width: 100%;
  min-height: 46px;
  /* a bowl, not a browser bar: flat rim, deep belly */
  border-radius: 0.85rem 0.85rem 1.7rem 1.7rem / 0.55rem 0.55rem 1.7rem 1.7rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 248, 238, 0.78);
  box-shadow: inset 0 2px 3px rgba(59, 36, 21, 0.12), inset 0 -1px 0 var(--highlight);
  padding-inline: 2.7rem 1rem;
  font-size: 1rem;
  transition: box-shadow 200ms var(--ease), background-color 200ms var(--ease);
}
#search:focus { background: rgba(255, 252, 246, 0.95); }
#search::placeholder { color: var(--ink-soft); opacity: 1; }

/* ---------- suggestions: a short list under the search, never a form ---------- */

.suggest {
  position: absolute;
  z-index: 6;
  inset-inline: 0;
  top: calc(100% + 0.35rem);
  border-radius: var(--radius);
  padding: 0.35rem;
  max-height: min(60vh, 25rem);
  overflow: auto;
  display: grid;
  gap: 0.1rem;
  /* the header already blurs what is behind it, so this list is solid to stay readable over the rows */
  background: #fffaf2;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  animation: suggest-in 180ms var(--ease) both;
}
.suggest-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 48px;
  padding: 0.2rem 0.5rem;
  border: 0;
  border-radius: 0.8rem;
  background: transparent;
  text-align: start;
}
.suggest-row:hover { background: rgba(255, 255, 255, 0.6); }
.suggest-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.05rem 0.4rem;
  font-weight: 700;
  line-height: 1.2;
}
.suggest-name { overflow-wrap: anywhere; }
.suggest-tag { font-size: 0.78rem; color: var(--ink-soft); font-weight: 500; white-space: nowrap; }
.suggest-plus {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--herb-wash);
  color: var(--herb);
}
.suggest-plus .icon { width: 1.1rem; height: 1.1rem; }
.suggest-row.is-add { margin-top: 0.1rem; border-top: 1px solid var(--edge); border-radius: 0 0 0.8rem 0.8rem; }
.suggest-plus.is-big { width: 2.1rem; height: 2.1rem; background: var(--herb); color: var(--on-fill); }
.suggest .warn { margin: 0.4rem 0.5rem 0.1rem; }
.suggest .note { margin: 0.3rem 0.5rem; }

.warn { color: var(--ink); font-size: 0.92rem; font-weight: 700; }
.note { color: var(--ink-soft); font-size: 0.92rem; margin: 0.2rem 0; }

.field-input {
  width: 100%;
  min-height: 48px;
  border-radius: 0.9rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 253, 249, 0.92);
  padding: 0 0.8rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.4rem 0 0;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--saffron-wash);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}
.sync.is-offline { background: var(--tomato-wash); }
.sync.is-syncing { background: var(--herb-wash); }

.attention {
  background: var(--tomato-wash);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0.5rem 0;
  display: grid;
  gap: 0.5rem;
}
.attention p { margin: 0; }
.attention-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ---------- column heads ---------- */

.columns {
  display: grid;
  grid-template-columns: var(--mark-size) minmax(0, 1fr) var(--qty-width) var(--qty-width);
  gap: 0.45rem;
  padding: 0.35rem calc(0.7rem + 1px) 0.3rem;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
}
.col-head {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.15rem 0.2rem;
  text-align: center;
}
.col-fridge .icon { color: var(--herb); }
.col-missing .icon { color: var(--tomato); }
.columns .icon { width: 0.95rem; height: 0.95rem; }

/* ---------- status blocks ---------- */

.status-block {
  text-align: center;
  padding: 1.6rem 1rem;
  color: var(--ink);
  display: grid;
  justify-items: center;
  gap: 0.5rem;
}
.status-block strong { font-size: 1.15rem; }
.empty-art { width: min(11rem, 60%); height: auto; }
.no-matches { list-style: none; }

.skeleton {
  height: 4.4rem;
  border-radius: var(--radius);
  margin-bottom: 0.55rem;
  background: linear-gradient(90deg, rgba(239, 224, 204, 0.85), rgba(255, 248, 238, 0.9) 45%, rgba(239, 224, 204, 0.85));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

/* ---------- rows ---------- */

#items { list-style: none; margin: 0.3rem 0 0; padding: 0; }

.row {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 280ms var(--ease), opacity 200ms var(--ease);
}
.row-main { min-height: 0; padding-bottom: 0.55rem; }
.row.is-removing, .row.is-entering { grid-template-rows: 0fr; opacity: 0; }
.row.is-removing .row-main, .row.is-entering .row-main { overflow: hidden; pointer-events: none; }

/* first paint only: the tickets settle in one after another, then everything is still */
.is-first-paint .row { animation: row-in 420ms var(--ease) both; }
.is-first-paint .row:nth-child(2) { animation-delay: 45ms; }
.is-first-paint .row:nth-child(3) { animation-delay: 90ms; }
.is-first-paint .row:nth-child(4) { animation-delay: 135ms; }
.is-first-paint .row:nth-child(5) { animation-delay: 180ms; }
.is-first-paint .row:nth-child(6) { animation-delay: 225ms; }
.is-first-paint .row:nth-child(7) { animation-delay: 270ms; }
.is-first-paint .row:nth-child(n + 8) { animation-delay: 315ms; }

.item {
  position: relative;
  z-index: 1;
  overflow: hidden;
  background: rgba(255, 248, 238, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--highlight), 0 0 0 1px var(--edge), 0 10px 20px -16px rgba(59, 36, 21, 0.55);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  transition: transform var(--t-press) var(--ease), box-shadow var(--t-dock) var(--ease), background-color var(--t-dock) var(--ease);
}
.item:active, .item.is-swiping { transform: translateY(1px); box-shadow: inset 0 2px 6px rgba(59, 36, 21, 0.2), 0 0 0 1px var(--edge); }
.row.is-open .item { box-shadow: inset 0 1px 0 var(--highlight), 0 0 0 1px var(--edge-strong), 0 12px 22px -16px rgba(59, 36, 21, 0.6); }
.item.is-swipe-armed { outline: 2px solid var(--herb); outline-offset: -2px; }

/* cart stain: a saffron fill under the name side, numbers stay on clean cream */
.row.is-in-cart .item::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 100%;
  background: linear-gradient(to right, rgba(224, 154, 43, 0.66), rgba(224, 154, 43, 0.4) 40%, rgba(224, 154, 43, 0) 70%);
  pointer-events: none;
}
[dir="rtl"] .row.is-in-cart .item::before {
  background: linear-gradient(to left, rgba(224, 154, 43, 0.66), rgba(224, 154, 43, 0.4) 40%, rgba(224, 154, 43, 0) 70%);
}
.row.is-washing .item::before { animation: cart-wash var(--t-wash) var(--ease) 1 both; }
.row.is-unwashing .item::before { animation: cart-unwash var(--t-wash) var(--ease) 1 both; }

.row.is-pending .item { border-style: dashed; border-color: var(--edge-strong); }
.row.is-loading .item { opacity: 0.75; }
.row.is-highlight .item { outline: 3px solid var(--herb); outline-offset: 2px; }

.item-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--mark-size) minmax(0, 1fr) var(--qty-width) var(--qty-width);
  gap: 0.45rem;
  align-items: center;
  min-height: 4rem;
  padding: 0.5rem 0.7rem;
}
.mark { width: var(--mark-size); height: var(--mark-size); display: block; }
.mark.is-hopping { animation: mark-hop 460ms var(--ease) 1; transform-origin: 50% 90%; }
.item-main { min-width: 0; }
.item-name {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.1rem 0.4rem;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.item-unit {
  background: var(--herb-wash);
  color: var(--ink);
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.1rem 0.5rem;
  min-height: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.item-meta:empty { display: none; }
.cart-ticket {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--ink);
  font-weight: 700;
}
.cart-ticket.is-stamping { animation: cart-stamp 380ms var(--ease) 1; }
.cart-ticket.is-leaving { animation: cart-leave 240ms ease-in 1 forwards; }
.cart-mark { width: 28px; height: 20px; display: block; }
.pending-dot { display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 500; }
.pending-dot .icon { width: 0.95rem; height: 0.95rem; }

.qty {
  text-align: center;
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.qty .num { display: inline-block; min-inline-size: 1ch; }
.qty .num.is-long { font-size: 1.15rem; }
.qty-fridge { color: var(--herb); }
.qty-missing { color: var(--tomato); }
.qty.is-zero { color: var(--ink-soft); font-weight: 500; }

.num.is-rising { animation: num-rise var(--t-tick) var(--ease) 1; }
.num.is-falling { animation: num-fall var(--t-tick) var(--ease) 1; }
/* finishing a shop: the old number is rubbed out and the new one typed in */
.num.is-typing::after {
  content: "";
  display: inline-block;
  inline-size: 2px;
  block-size: 0.85em;
  margin-inline-start: 2px;
  background: currentColor;
  vertical-align: -0.06em;
  animation: caret 640ms steps(1) infinite;
}

/* ---------- drawer: dock grows down, the ticket never moves ---------- */

.drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-dock) var(--ease);
}
.row.is-open .drawer { grid-template-rows: 1fr; }
.drawer-inner { min-height: 0; overflow: hidden; }
.drawer-pad { padding: 0.5rem 0.35rem 0.2rem; display: grid; gap: 0.1rem; }

.dock {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}
.dock-slot { display: grid; }
.dock-btn {
  grid-area: 1 / 1;
  min-height: 52px;
  border: 1px solid var(--glass-edge);
  border-radius: 0.9rem;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--highlight), 0 8px 16px -12px rgba(59, 36, 21, 0.55);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem;
  opacity: 1;
  transition:
    transform var(--t-press) var(--ease),
    box-shadow 160ms var(--ease),
    opacity var(--t-morph) var(--ease),
    visibility 0s linear 0s;
}
.dock-btn span { line-height: 1.1; }
.dock-btn.tone-cart { background: var(--saffron); border-color: transparent; }
.dock-btn.tone-fridge { background: rgba(223, 233, 214, 0.9); }
.dock-btn.tone-fridge .icon { color: var(--herb); }
.dock-btn.tone-delete { background: var(--tomato); border-color: transparent; color: var(--on-fill); }

/* one hit-box per slot: the set that is off fades out, then cannot be seen, focused or hit */
.row:not(.mode-edit) .dock-btn[data-set="edit"],
.row.mode-edit .dock-btn[data-set="actions"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform var(--t-press) var(--ease),
    opacity var(--t-morph) var(--ease),
    visibility 0s linear var(--t-morph);
}

/* panels under the dock */
.panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-dock) var(--ease);
}
.panel.is-open { grid-template-rows: 1fr; }
.panel-inner { min-height: 0; overflow: hidden; }
.panel-body { padding: 0.5rem 0.1rem 0.25rem; }

/* ---------- wheel ---------- */

.wheel, .edit {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--highlight), 0 0 0 1px var(--edge), var(--lift);
}
.wheel {
  padding: 0.4rem 0.6rem 0.6rem;
  display: grid;
  gap: 0.2rem;
}
.wheel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 700;
  min-height: 44px;
}
.wheel-title { display: inline-flex; align-items: center; gap: 0.4rem; }
.wheel-unit { font-weight: 500; color: var(--ink-soft); font-size: 0.85rem; }
.wheel-body { display: flex; align-items: center; gap: 0.6rem; }
.wheel-window { position: relative; flex: 1; min-width: 0; }
.wheel-track {
  height: calc(var(--row-h) * 3);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-radius: 0.8rem;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
.wheel-track::-webkit-scrollbar { display: none; }
.wheel-pad { height: var(--row-h); }
.wheel-static { overflow: hidden; scroll-snap-type: none; display: grid; grid-template-rows: repeat(3, var(--row-h)); }
.wheel-value {
  height: var(--row-h);
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform var(--t-wheel) var(--ease), color var(--t-wheel) var(--ease);
}
.wheel-value.is-selected {
  color: var(--ink);
  font-weight: 700;
  transform: scale(1.5);
}
.wheel-lens {
  position: absolute;
  inset-inline: 0.2rem;
  top: var(--row-h);
  height: var(--row-h);
  border-block: 1px solid var(--edge-strong);
  pointer-events: none;
}
.wheel-confirm {
  flex: none;
  width: 56px;
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--herb);
  color: var(--on-fill);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 18px -12px rgba(47, 107, 69, 0.9);
}
.wheel-confirm .icon { width: 1.6rem; height: 1.6rem; }

/* ---------- edit panel ---------- */

.edit {
  padding: 0.75rem;
  display: grid;
  gap: 0.65rem;
}
.field { display: grid; gap: 0.25rem; font-size: 0.8rem; color: var(--ink-soft); font-weight: 700; }
.field input {
  min-height: 44px;
  border-radius: 0.8rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 253, 249, 0.92);
  padding: 0 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  width: 100%;
}
.name-row { display: flex; align-items: center; gap: 0.5rem; }
.name-row .field-input { flex: 1; min-width: 0; }
.icon-chip {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 0.9rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 253, 249, 0.92);
  display: grid;
  place-items: center;
}
.icon-chip[aria-expanded="true"] { border-color: var(--herb); box-shadow: 0 0 0 3px rgba(47, 107, 69, 0.22); }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 0.3rem;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--edge);
  border-radius: 0.9rem;
}
.icon-tile {
  width: 100%;
  min-height: 46px;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 0.8rem;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}
.icon-tile img { width: 32px; height: 32px; }
.icon-tile .icon { width: 1.5rem; height: 1.5rem; }
.icon-tile.is-on { border-color: var(--herb); background: var(--herb-wash); }
.unit-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.unit-pill {
  min-height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid var(--edge-strong);
  background: rgba(243, 230, 212, 0.8);
  padding: 0 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.unit-pill.is-on { background: var(--herb); color: var(--on-fill); border-color: var(--herb); }
.price-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.price-chip {
  min-height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid var(--edge-strong);
  background: var(--saffron-wash);
  color: var(--ink);
  padding: 0 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.price-chip > span { font-size: 1.2rem; line-height: 1; }
.price-chip[aria-expanded="true"] { background: var(--saffron); border-color: transparent; }
.price-field { flex: 1 1 8rem; min-width: 7rem; }

/* ---------- add sheet ---------- */

.sheet { width: min(30rem, calc(100% - 1rem)); }
.add-form { display: grid; gap: 0.8rem; }
.add-form h2 { margin: 0; }
.add-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.add-note:empty { display: none; }
.stepper { display: flex; align-items: center; gap: 0.5rem; }
.stepper-btn {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--edge-strong);
  background: var(--glass-strong);
  display: grid;
  place-items: center;
  color: var(--ink);
}
.stepper-btn:disabled { opacity: 0.4; cursor: default; }
.stepper-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border-radius: 0.9rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 253, 249, 0.92);
}

/* ---------- FAB + finish bar ---------- */

.fab {
  position: fixed;
  z-index: 7;
  inset-inline-end: max(var(--page-pad), calc((100% - 42rem) / 2 + var(--page-pad)));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: 3.6rem;
  height: 3.6rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(160deg, #3b8056, var(--herb) 55%);
  color: var(--on-fill);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 12px 22px -12px rgba(47, 107, 69, 0.95);
  display: grid;
  place-items: center;
}
.fab .icon { width: 1.7rem; height: 1.7rem; }

/* the finish bar sits beside the FAB on the same baseline, never above or under it */
.finish-bar {
  position: fixed;
  z-index: 7;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  inset-inline-start: max(var(--page-pad), calc((100% - 42rem) / 2 + var(--page-pad)));
  inset-inline-end: max(calc(var(--page-pad) + 3.6rem + 0.6rem), calc((100% - 42rem) / 2 + var(--page-pad) + 3.6rem + 0.6rem));
  min-height: 3.6rem;
  background: linear-gradient(180deg, #e8a63f, var(--saffron) 60%);
  color: var(--ink);
  border: 1px solid rgba(59, 36, 21, 0.18);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem;
  padding-inline: 0.9rem 0.35rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 12px 22px -12px rgba(150, 90, 10, 0.8);
  animation: bar-in 320ms var(--ease) both;
}
.finish-text { flex: 1; min-width: 0; line-height: 1.15; }
#finish-count { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finish-meta { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finish-btn {
  flex: none;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-fill);
  font-weight: 700;
  padding: 0 1rem;
}

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--glass-edge);
  border-radius: 1.25rem;
  padding: 0;
  width: min(28rem, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  backdrop-filter: blur(22px) saturate(1.35);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 26px 50px -24px rgba(59, 36, 21, 0.7);
}
dialog[open] { animation: dialog-in 240ms var(--ease) both; }
dialog::backdrop { background: rgba(59, 36, 21, 0.4); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
dialog[open]::backdrop { animation: fade-in 240ms ease both; }
.dialog-body { padding: 1rem; }
dialog h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.dialog-actions { display: flex; gap: 0.45rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 0.9rem; }
.ticket-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--saffron-wash);
  border: 1px solid var(--edge);
  border-radius: 0.8rem;
}
.ticket-line .ticket-name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.preview-total { font-weight: 700; margin-top: 0.6rem; }
#share-url { direction: ltr; text-align: left; }
.stack-label { display: grid; gap: 0.25rem; font-size: 0.85rem; color: var(--ink-soft); }
.stack-label input {
  width: 100%;
  min-height: 44px;
  border-radius: 0.8rem;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 253, 249, 0.92);
  padding: 0 0.7rem;
  font-size: 1rem;
  color: var(--ink);
}
.log-card { padding: 0.55rem 0; border-bottom: 1px solid var(--edge); }
.log-card h3 { margin: 0; font-size: 1rem; }
.log-card p { margin: 0.15rem 0; color: var(--ink-soft); font-size: 0.9rem; }
#logs-body { max-height: 55vh; overflow: auto; }

/* ---------- tutorial: three beats on a local sample row, never sent anywhere ---------- */

.tutorial h2 { margin-bottom: 0.6rem; }
.demo { pointer-events: none; }
.demo .row-main { padding-bottom: 0; }
.demo-line { margin: 0.8rem 0 0.2rem; min-height: 1.6rem; font-weight: 700; text-align: center; }
.beats { display: flex; justify-content: center; gap: 0.2rem; }
.beat {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.beat::after {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--edge-strong);
  transition: background var(--t-morph) var(--ease), transform var(--t-morph) var(--ease);
}
.beat[aria-current="true"]::after { background: var(--herb); transform: scale(1.35); }
.tutorial .dialog-actions { justify-content: center; }
.tutorial .primary-btn { min-width: 10rem; }

/* ---------- celebration ---------- */

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.celebrate-card {
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  border-radius: 1.4rem;
  padding: 1.2rem 1.6rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 26px 50px -24px rgba(59, 36, 21, 0.7);
  text-align: center;
  font-weight: 700;
  position: relative;
  animation: dialog-in 280ms var(--ease) both;
}
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 99px;
  inset-inline-start: calc(50% - 5px);
  top: calc(50% - 5px);
  animation: burst 0.9s var(--ease) forwards;
}
.burst i:nth-child(4n + 1) { background: var(--herb); }
.burst i:nth-child(4n + 2) { background: var(--tomato); }
.burst i:nth-child(4n + 3) { background: var(--saffron); }
.burst i:nth-child(4n) { background: var(--ink); }
.burst i:nth-child(1)  { --x: 78px;  --y: 0px; }
.burst i:nth-child(2)  { --x: 68px;  --y: 39px; }
.burst i:nth-child(3)  { --x: 39px;  --y: 68px; }
.burst i:nth-child(4)  { --x: 0px;   --y: 78px; }
.burst i:nth-child(5)  { --x: -39px; --y: 68px; }
.burst i:nth-child(6)  { --x: -68px; --y: 39px; }
.burst i:nth-child(7)  { --x: -78px; --y: 0px; }
.burst i:nth-child(8)  { --x: -68px; --y: -39px; }
.burst i:nth-child(9)  { --x: -39px; --y: -68px; }
.burst i:nth-child(10) { --x: 0px;   --y: -78px; }
.burst i:nth-child(11) { --x: 39px;  --y: -68px; }
.burst i:nth-child(12) { --x: 68px;  --y: -39px; }

/* ---------- keyframes ---------- */

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes still-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(3px, -3px, 0); }
}
@keyframes cart-wash {
  from { inline-size: 0; }
  to { inline-size: 100%; }
}
@keyframes cart-unwash {
  from { inline-size: 100%; }
  to { inline-size: 0; }
}
@keyframes cart-stamp {
  0% { transform: scale(2.2) rotate(-16deg); opacity: 0; }
  55% { transform: scale(0.9) rotate(3deg); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes cart-leave {
  to { transform: translateY(-8px) scale(0.6) rotate(10deg); opacity: 0; }
}
@keyframes mark-hop {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-10px) scale(1.16) rotate(-7deg); }
  62% { transform: translateY(1px) scale(0.94) rotate(3deg); }
  100% { transform: none; }
}
@keyframes num-rise {
  from { transform: translateY(45%); opacity: 0.2; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes num-fall {
  from { transform: translateY(-45%); opacity: 0.2; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes caret {
  50% { opacity: 0; }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(12px); }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}
@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes suggest-in {
  from { opacity: 0; transform: translateY(-6px); }
}
@keyframes bar-in {
  from { opacity: 0; transform: translateY(14px); }
}
@keyframes burst {
  to { transform: translate(var(--x), var(--y)); opacity: 0; }
}

@media (max-width: 340px) {
  :root { --page-pad: 0.7rem; --qty-width: 3.1rem; }
  .list-title { font-size: 1.12rem; }
  .qty { font-size: 1.5rem; }
  .item-body { gap: 0.35rem; padding-inline: 0.6rem; }
  .columns { gap: 0.35rem; padding-inline: calc(0.6rem + 1px); }
}
/* the mark shrinks before the name does */
@media (max-width: 300px) {
  :root { --mark-size: 24px; }
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover, .primary-btn:hover, .dock-btn:hover, .unit-pill:hover, .icon-tile:hover { filter: brightness(1.05); }
  .item:hover { box-shadow: inset 0 1px 0 var(--highlight), 0 0 0 1px var(--edge-strong), 0 12px 22px -16px rgba(59, 36, 21, 0.6); }
}

/* No blur available, or the person asked for less transparency or more contrast: solid paper instead. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: var(--cream); --glass-strong: var(--cream); }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--cream); --glass-strong: var(--cream); }
  .glass, .top, .dock-btn, .wheel, .edit, dialog, .celebrate-card, dialog::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-contrast: more) {
  body::before { display: none; }
  :root { --glass: var(--cream); --glass-strong: var(--cream); --edge-strong: rgba(59, 36, 21, 0.5); }
  .item { background: var(--cream); }
}

/* Reduced motion: no drift, wash, hop, stamp, tick, typing, burst or settle. The dock still opens and closes, instantly. */
@media (prefers-reduced-motion: reduce) {
  .still-life, .skeleton, .suggest, .finish-bar, .celebrate-card { animation: none; }
  .is-first-paint .row { animation: none; }
  .row.is-washing .item::before, .row.is-unwashing .item::before { animation: none; }
  .mark.is-hopping, .cart-ticket.is-stamping { animation: none; }
  .cart-ticket.is-leaving { animation: none; opacity: 0; }
  .num.is-rising, .num.is-falling { animation: none; }
  .num.is-typing::after { animation: none; }
  dialog[open], dialog[open]::backdrop { animation: none; }
  .burst { display: none; }
  .row, .drawer, .panel, .item, .shell, #search { transition: none; }
  button, .wheel-value, .beat::after { transition: none; }
  .row .dock-btn { transition: none !important; }
  button:active:not(:disabled), .item:active, .item.is-swiping { transform: none; }
  html { scroll-behavior: auto; }
}
