/* Trolley — a shopping list that walks the shop with you.
   One pane on phones (List / Map tabs); on the iPhone Duo opened out (or any screen 700px+)
   the list and the map sit side by side, and on fold-aware browsers they snap to the fold. */

:root {
  --bg: #F6F4EF; --card: #FFFFFF; --ink: #1B2230; --muted: #687080; --faint: #A3A8B2;
  --line: #E7E3DB; --soft: #EFECE5; --road: #E2DDD3; --shadow: 0 1px 2px rgb(30 30 40 / .06), 0 8px 24px rgb(30 30 40 / .07);
  --accent: #0A57C2; --accent-ink: #FFFFFF; --hi: #FFD400; --accent-soft: #E3ECFA;
  --slate: #3C4655;
  --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px);
  --pad-l: max(16px, var(--sa-l)); --pad-r: max(16px, var(--sa-r));
  --round: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px; --tint-mix: 70%; --dot-mix: 80%;
  color-scheme: light dark;
}
#app[data-store="sains"] { --accent: #E8650A; --hi: #FFC46B; --accent-soft: #FCE8D8; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317; --card: #1A1E24; --ink: #F1EFEA; --muted: #9AA2AE; --faint: #626B78;
    --line: #2A3039; --soft: #222831; --road: #2B323C; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    --accent: #5B9BFF; --accent-ink: #0B1220; --hi: #FFD84D; --accent-soft: #1B2A44; --slate: #4A5566; --tint-mix: 16%; --dot-mix: 24%;
  }
  #app[data-store="sains"] { --accent: #FF8F3D; --hi: #FFC46B; --accent-soft: #3A2616; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--ink); font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 1em; height: 1em; }
.defs { position: absolute; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }

#app {
  height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  transition: background .3s;
}
#app[data-mode="plan"] .shop-only, #app[data-mode="shop"] .plan-only { display: none !important; }

/* ---------- Header: store switch ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--sa-t) + 10px) var(--pad-r) 10px var(--pad-l);
}
.stores {
  position: relative; flex: 1; display: grid; grid-template-columns: 1fr 1fr; padding: 4px;
  background: var(--soft); border-radius: 16px; min-width: 0;
}
.stores button {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 7px 6px; border-radius: 12px; min-height: 48px; color: var(--muted); transition: color .25s;
}
.stores b { font: 700 16px/1.1 var(--round); letter-spacing: -.01em; white-space: nowrap; }
.stores small { font-size: 12px; opacity: .85; white-space: nowrap; }
.stores button[aria-selected="true"] { color: var(--accent-ink); }
.stores .slider {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 12px;
  background: var(--accent); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .35s cubic-bezier(.3, 1.3, .5, 1), background .3s;
}
#app[data-store="sains"] .stores .slider { transform: translateX(100%); }

.avatar {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%;
  background: var(--me, var(--slate)); color: #fff; font: 700 19px var(--round);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.avatar i {
  position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; border-radius: 50%;
  border: 2.5px solid var(--bg); background: var(--faint);
}
.avatar i[data-s="synced"] { background: #3DBE7A; }
.avatar i[data-s="syncing"] { background: #3DBE7A; animation: blink 1s infinite; }
.avatar i[data-s="offline"], .avatar i[data-s="error"] { background: #E8A33D; }
.avatar i[data-s="solo"] { display: none; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Panes ---------- */
.panes { position: relative; min-height: 0; display: grid; }
.pane { min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#app[data-tab="list"] .map-pane, #app[data-tab="map"] .list-pane { display: none; }
.list-pane { padding: 4px var(--pad-r) 0 var(--pad-l); }

@media (min-width: 700px), (horizontal-viewport-segments: 2) {
  .panes { grid-template-columns: minmax(340px, 1fr) minmax(320px, 1fr); }
  #app .list-pane, #app .map-pane { display: block !important; }
  .map-pane { border-left: 1px solid var(--line); }
  .list-pane { padding-right: 16px; }
  .tabs { display: none !important; }
  /* keep the controls on the list side of the fold */
  .top .stores { flex: 0 1 calc(50% - var(--pad-l) - 16px); }
  .top .avatar { margin-left: auto; }
  .dock .go { flex: 0 1 calc(50% - var(--pad-l) - 16px); }
}
@media (horizontal-viewport-segments: 2) {
  :root { --fold: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px)); }
  .panes { grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0); column-gap: var(--fold); }
  .map-pane { border-left: 0; }
}

/* ---------- Add bar ---------- */
.add { position: sticky; top: 0; z-index: 5; padding: 6px 0 10px; background: linear-gradient(var(--bg) 82%, transparent); }
.add-row { display: flex; gap: 8px; }
.add input {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font: 17px system-ui, sans-serif; outline: none; box-shadow: var(--shadow);
  transition: border-color .2s;
}
.add input:focus { border-color: var(--accent); }
.add input::placeholder { color: var(--faint); }
.add-btn {
  flex: none; width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 24px; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: transform .15s, background .3s;
}
.add-btn:active { transform: scale(.92); }
.suggest {
  position: absolute; left: 0; right: 60px; top: 62px; z-index: 6; background: var(--card); border-radius: 16px;
  box-shadow: 0 12px 40px rgb(20 20 30 / .18); border: 1px solid var(--line); overflow: hidden;
}
.suggest button {
  display: flex; width: 100%; align-items: center; gap: 12px; padding: 11px 14px; text-align: left; min-height: 52px;
}
.suggest button + button { border-top: 1px solid var(--line); }
.suggest button[aria-selected="true"], .suggest button:active { background: var(--soft); }
.suggest .emo { font-size: 24px; width: 30px; text-align: center; }
.suggest .s-name { flex: 1; font-weight: 600; }
.suggest .s-where { font-size: 13px; color: var(--muted); text-align: right; max-width: 45%; }

.usuals { display: flex; gap: 8px; overflow-x: auto; padding: 0 2px 12px; margin: 0 calc(-1 * var(--pad-r)) 0 calc(-1 * var(--pad-l)); padding-left: var(--pad-l); padding-right: var(--pad-r); scrollbar-width: none; }
.usuals::-webkit-scrollbar { display: none; }
.usuals .label { flex: none; align-self: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px;
  border-radius: 20px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 15px;
  white-space: nowrap; transition: transform .15s;
}
.chip:active { transform: scale(.94); }
.chip .emo { font-size: 20px; }
.chip.pop { animation: pop .4s; }
@keyframes pop { 40% { transform: scale(1.12); } }

.banner {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 12px; border-radius: 16px;
  background: var(--accent-soft); font-size: 14px;
}
.banner .b-emo { font-size: 26px; }
.banner p { margin: 0; flex: 1; }
.banner button { font-weight: 700; color: var(--accent); padding: 8px 4px; white-space: nowrap; }

/* ---------- Groups (one per aisle) ---------- */
.groups { list-style: none; margin: 0; padding: 0; }
.group { margin-bottom: 14px; }
.g-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 4px; text-align: left;
  position: sticky; top: 68px; z-index: 2; background: var(--bg);
}
#app[data-mode="shop"] .g-head { top: 0; }
#app[data-mode="shop"] .add { position: relative; background: none; }
.group { scroll-margin-top: 70px; }
#app[data-mode="shop"] .group { scroll-margin-top: 4px; }
.g-num {
  flex: none; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 800 16px var(--round); transition: background .3s;
}
.g-num.stop { background: var(--soft); color: var(--muted); }
.g-title { flex: 1; min-width: 0; }
.g-title b { display: block; font: 700 17px/1.2 var(--round); letter-spacing: -.01em; }
.g-title small { color: var(--muted); font-size: 13px; }
.g-count { font: 700 14px var(--round); color: var(--muted); }
.g-emo { font-size: 22px; }
.group.unsorted .g-num { background: var(--soft); color: var(--muted); }

.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { position: relative; touch-action: pan-y; -webkit-touch-callout: none; overflow: hidden; }
.item .row {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px 8px 8px;
  background: var(--card); transition: background .2s;
}
.item + .item { border-top: 1px solid var(--line); }
.item .tick {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--tint, #EEE) var(--tint-mix), var(--card)); font-size: 25px; transition: transform .2s;
}
.item .tick:active { transform: scale(.9); }
.item .tick svg {
  position: absolute; inset: 0; margin: auto; width: 28px; height: 28px; color: var(--accent-ink);
  opacity: 0; transform: scale(.4); transition: opacity .2s, transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-self: stretch; text-align: left; }
.item .name { font-size: 17px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.item .qty {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 9px; background: var(--soft);
  font: 700 14px var(--round); vertical-align: 1px;
}
.item .note { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.item .tag { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.item .who {
  flex: none; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: var(--c, var(--slate)); color: #fff;
  display: grid; place-items: center; font: 700 11px var(--round); opacity: .9;
}
.item.done .tick { background: var(--accent); }
.item.done .tick .emo { opacity: 0; }
.item.done .tick svg { opacity: 1; transform: none; }
.item.done .name { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 2px; }
.item.done .qty, .item.done .note { opacity: .5; }
.item.missed .name { color: var(--muted); }
.item.flash .row { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { background: var(--accent-soft); } }
.item.swiping .row { transition: none; }
.swipe-under {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 20px;
  background: var(--slate); color: #fff; font-weight: 700; font-size: 15px;
}

/* Shop mode: bigger rows, the current aisle stands out, finished aisles fold away */
#app[data-mode="shop"] .item .row { min-height: 68px; }
#app[data-mode="shop"] .item .name { font-size: 19px; }
#app[data-mode="shop"] .group.current .items { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow); }
.group.complete .items { display: none; }
.group.complete .g-num { background: var(--soft); color: var(--accent); }
.group.complete .g-title b { color: var(--muted); }
.group.complete.open .items { display: block; }
.g-done { display: none; color: var(--accent); font-size: 20px; }
.group.complete .g-done { display: block; }

.empty { text-align: center; padding: 40px 24px; color: var(--muted); }
.empty-trolley { width: 96px; height: 96px; color: var(--accent); opacity: .85; animation: roll 3s ease-in-out infinite; }
@keyframes roll { 0%, 100% { transform: translateX(-10px) rotate(-2deg); } 50% { transform: translateX(10px) rotate(2deg); } }
.empty h2 { font: 700 21px var(--round); color: var(--ink); margin: 12px 0 6px; }
.empty p { margin: 0 auto; max-width: 300px; }
.list-end { height: 24px; }

/* ---------- Shop header ---------- */
.shopbar { min-width: 0; padding: calc(var(--sa-t) + 8px) var(--pad-r) 6px var(--pad-l); background: var(--bg); }
.shop-title { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); font-size: 20px; }
.shop-name { flex: 1; min-width: 0; }
.shop-name b { display: block; font: 800 19px/1.15 var(--round); }
.shop-name small { color: var(--muted); font-size: 14px; }
.ring { position: relative; width: 48px; height: 48px; }
.ring svg { width: 48px; height: 48px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: var(--soft); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke-dashoffset .5s cubic-bezier(.3, 1, .5, 1); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 800 13px var(--round); }

.strip {
  display: flex; align-items: flex-end; gap: 0; overflow-x: auto; padding: 22px 6px 6px; margin: 4px calc(-1 * var(--pad-r)) 0 calc(-1 * var(--pad-l));
  padding-left: var(--pad-l); padding-right: var(--pad-r); scrollbar-width: none; scroll-behavior: smooth;
}
.strip::-webkit-scrollbar { display: none; }
.stop {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow); font-size: 22px; transition: transform .3s, background .3s;
}
.stop-line { flex: none; width: 18px; height: 4px; margin-bottom: 21px; border-radius: 2px; background: var(--road); }
.stop-line.done { background: var(--accent); }
.stop.done { background: var(--accent); }
.stop.done .emo { opacity: .25; }
.stop.done::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 22px; height: 22px;
  background: var(--accent-ink); -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="black" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>') center/contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="black" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>') center/contain no-repeat;
}
.stop.current { transform: scale(1.18); box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.stop.current::before {
  content: ""; position: absolute; top: -24px; left: 50%; width: 24px; height: 24px; margin-left: -12px;
  background: var(--accent); animation: bob 1.4s ease-in-out infinite;
  -webkit-mask: url('icons/trolley-mask.svg') center/contain no-repeat; mask: url('icons/trolley-mask.svg') center/contain no-repeat;
}
@keyframes bob { 50% { transform: translateY(-3px); } }
.stop small {
  position: absolute; bottom: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--ink); color: var(--bg); font: 800 11px/18px var(--round); text-align: center;
}
.stop.done small { display: none; }

/* ---------- Map ---------- */
.map-pane { padding: 0 var(--pad-r) 0 var(--pad-l); }
.map-head { position: sticky; top: 0; z-index: 4; padding: 10px 0 8px; background: linear-gradient(var(--bg) 85%, transparent); }
.map-title b { display: block; font: 800 20px/1.15 var(--round); }
.map-title small { color: var(--muted); font-size: 13.5px; }
.find {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; height: 46px; padding: 0 14px; border-radius: 14px;
  background: var(--card); border: 1.5px solid var(--line); color: var(--muted); font-size: 18px; box-shadow: var(--shadow);
}
.find:focus-within { border-color: var(--accent); }
.find input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 16px system-ui, sans-serif; color: var(--ink); }
.find-answer { margin: 10px 2px 0; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }
.find-answer b { font-weight: 700; }

.map { position: relative; margin: 6px 0 0; }
.road { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.road .bed { fill: none; stroke: var(--road); stroke-width: 16; stroke-linecap: round; }
.road .dash { fill: none; stroke: var(--bg); stroke-width: 2; stroke-dasharray: 2 10; stroke-linecap: round; opacity: .9; }
.road .walked { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; opacity: .85; transition: stroke .3s; }

.stn { position: absolute; display: flex; align-items: center; gap: 10px; transform: translateY(-50%); text-align: left; }
.stn.r { flex-direction: row-reverse; text-align: right; }
.stn .dot {
  position: relative; flex: none; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; background: color-mix(in srgb, var(--tint, #EEE) var(--dot-mix), var(--card)); box-shadow: 0 0 0 4px var(--bg), var(--shadow);
  transition: transform .3s, box-shadow .3s;
}
.stn.has .dot { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--accent), var(--shadow); }
.stn .badge {
  position: absolute; top: -4px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink); font: 800 12.5px/22px var(--round); text-align: center;
}
.stn .card {
  max-width: var(--lw); padding: 8px 12px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
}
.stn .card b { display: block; font: 700 15px/1.2 var(--round); }
.stn .card small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.stn .card .emos { display: block; font-size: 17px; letter-spacing: 1px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stn.empty .dot { width: 40px; height: 40px; font-size: 19px; margin: 0 9px; opacity: .6; filter: saturate(.5); }
.stn.empty .card { background: transparent; box-shadow: none; padding: 4px 6px; }
.stn.empty .card b { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.stn.empty .card small { display: none; }
.stn.done .dot { opacity: .55; }
.stn.done .badge { background: var(--muted); }
.stn.cur .dot { transform: scale(1.12); }
.stn.found .dot { animation: found 1.1s ease-in-out 3; }
@keyframes found { 50% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 14px color-mix(in srgb, var(--hi) 80%, transparent), var(--shadow); transform: scale(1.15); } }
.stn.end .dot { background: var(--soft); width: 46px; height: 46px; font-size: 22px; margin: 0 6px; }
.stn.end .card { background: transparent; box-shadow: none; }

.trolley-pin {
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -40px 0 0 -17px; color: var(--accent);
  pointer-events: none; z-index: 3;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / .18));
}
.map.ready .trolley-pin { transition: transform .8s cubic-bezier(.4, 1.2, .5, 1), color .3s; }
.trolley-pin svg { width: 34px; height: 34px; animation: bob 1.4s ease-in-out infinite; }
.map-note { font-size: 13px; color: var(--muted); text-align: center; margin: 4px 12px 28px; }
.map-note button { color: var(--accent); font-weight: 700; padding: 6px 2px; }

/* ---------- Dock ---------- */
.dock {
  display: flex; gap: 10px; align-items: center;
  padding: 10px var(--pad-r) calc(var(--sa-b) + 10px) var(--pad-l);
  background: linear-gradient(transparent, var(--bg) 30%);
}
.tabs { display: flex; padding: 4px; border-radius: 18px; background: var(--soft); }
.tabs button {
  width: 56px; height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; color: var(--muted); font-size: 21px;
}
.tabs button span { font-size: 11px; font-weight: 700; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.go {
  flex: 1; min-width: 0; height: 60px; border-radius: 18px; background: var(--accent); color: var(--accent-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .15s, background .3s, opacity .3s;
}
.go span { font: 800 18px var(--round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.go small { font-size: 12.5px; opacity: .85; font-weight: 600; }
.go:active { transform: scale(.97); }
.go:disabled { opacity: .45; box-shadow: none; }
.go.finish { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.go.finish.ready { background: var(--accent); color: var(--accent-ink); animation: pop .5s; }

/* ---------- Sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgb(10 12 16 / .38); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / .2);
  padding: 8px var(--pad-r) calc(var(--sa-b) + 18px) var(--pad-l); animation: up .3s cubic-bezier(.2, 1, .3, 1);
}
@keyframes up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: min(520px, 94vw); transform: translateX(-50%); bottom: 16px; border-radius: 24px; padding-bottom: 20px; animation: upc .3s cubic-bezier(.2, 1, .3, 1); }
  @keyframes upc { from { transform: translate(-50%, 30px); opacity: 0; } }
}
@media (horizontal-viewport-segments: 2) {
  .sheet { left: calc(env(viewport-segment-left 1 0) + 12px); right: 12px; width: auto; transform: none; animation: up .3s; }
}
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font: 800 22px/1.2 var(--round); margin: 4px 0 4px; letter-spacing: -.01em; }
.sheet h3 { font: 700 14px var(--round); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.sheet p { margin: 6px 0; color: var(--muted); }
.sheet .lead { font-size: 15.5px; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px 4px; }
.field input, .field select {
  width: 100%; height: 50px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink); font: 17px system-ui, sans-serif; outline: none; -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 18px;
  border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); font-weight: 700; font-size: 16px; margin-top: 10px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn:active { transform: scale(.98); }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btns .btn { margin-top: 10px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--bg); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--c); }
.card-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 16px; margin: 8px 0;
  box-shadow: var(--shadow); width: 100%; text-align: left; min-height: 56px;
}
.card-row .emo { font-size: 24px; }
.card-row div { flex: 1; min-width: 0; }
.card-row b { display: block; font-weight: 700; }
.card-row small { color: var(--muted); font-size: 13.5px; }
.card-row .go-arrow { color: var(--faint); font-size: 22px; }
.members { display: flex; flex-wrap: wrap; gap: 8px; }
.member { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 20px; background: var(--card); font-weight: 600; box-shadow: var(--shadow); }
.member i { width: 28px; height: 28px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font: 700 13px var(--round); font-style: normal; }
.qr { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: 20px; margin: 12px auto; width: fit-content; }
.qr svg { width: 220px; height: 220px; }
.aisle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.aisle-pick {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--card);
  border: 1.5px solid var(--line); text-align: left; min-height: 56px; font-size: 14.5px; font-weight: 600; line-height: 1.2;
}
.aisle-pick .emo { font-size: 22px; }
.aisle-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.route-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; background: var(--card); border-radius: 16px; margin: 8px 0; box-shadow: var(--shadow); }
.route-row .emo { font-size: 22px; }
.route-row .r-main { flex: 1; min-width: 0; }
.route-row input.r-label { width: 100%; border: 0; background: none; font: 700 16px var(--round); color: var(--ink); outline: none; padding: 2px 0; }
.route-row .r-cats { font-size: 12.5px; color: var(--muted); }
.route-row input.r-num {
  width: 52px; height: 40px; text-align: center; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg);
  font: 700 15px var(--round); color: var(--ink); outline: none;
}
.route-row .mv { width: 36px; height: 36px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; font-size: 18px; }
.route-row .mv:disabled { opacity: .3; }
.stat-row { display: flex; gap: 10px; margin: 14px 0; }
.stat { flex: 1; padding: 14px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.stat b { display: block; font: 800 26px var(--round); color: var(--accent); }
.stat small { color: var(--muted); font-size: 13px; }
.hint { font-size: 13.5px; color: var(--muted); }
.walk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; font-size: 22px; }
.walk i { font-style: normal; color: var(--faint); font-size: 14px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--sa-b) + 92px); z-index: 30; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 460px; padding: 12px 14px 12px 16px;
  border-radius: 16px; background: var(--ink); color: var(--bg); box-shadow: 0 10px 30px rgb(0 0 0 / .25);
  font-size: 15px; font-weight: 500; animation: toast .3s cubic-bezier(.2, 1.3, .4, 1);
}
.toast .emo { font-size: 20px; }
.toast button { color: var(--hi); font-weight: 800; padding: 6px 4px; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(10px); transition: .25s; }
@keyframes toast { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@media (horizontal-viewport-segments: 2) { .toasts { left: 0; right: auto; width: env(viewport-segment-width 0 0); } }

@media (max-width: 380px) {
  .stores b { font-size: 15px; }
  .stores small { font-size: 11px; }
  .tabs button { width: 50px; }
  .go span { font-size: 16.5px; }
}
