/* Shopping — styles. Tokens on :root, dark via prefers-color-scheme. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef3;
  --text: #15202b;
  --muted: #5f6b7a;
  --border: #d9dfe7;
  --accent: #1b5fa6;
  --accent-text: #ffffff;
  --accent-soft: #e3ecf8;
  --danger: #c62828;
  --ok: #2e7d32;
  --warn: #c77800;
  --busy: #1b5fa6;
  --off: #8a94a3;
  --shadow: 0 8px 30px rgba(15, 23, 32, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --row-h: 52px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --addbar-h: 118px;          /* measured at runtime (ResizeObserver); includes safe-area padding */
  --kb-offset: 0px;           /* height of the on-screen keyboard covering the layout viewport (iOS) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --focus: 0 0 0 3px var(--accent-soft), 0 0 0 5px var(--accent);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --surface: #18222e;
    --surface-2: #212d3b;
    --text: #e8edf3;
    --muted: #93a1b3;
    --border: #2c3a4a;
    --accent: #5c9ce6;
    --accent-text: #0b1a2c;
    --accent-soft: #1d2f45;
    --danger: #ff6b6b;
    --ok: #5dc26b;
    --warn: #f0a82c;
    --busy: #5c9ce6;
    --off: #6b7684;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* body must grow with the list: a body capped at 100% height would carry the sticky header off-screen */
html { height: 100%; }
body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sheet-header h2:focus-visible, .card h2:focus-visible { box-shadow: none; }
body.sheet-open, body.auth-open { overflow: hidden; }
svg.sprite { position: absolute; width: 0; height: 0; }

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px var(--gutter) 4px;
  min-height: 56px;
}
/* spec A-50: title · ☆ · pill · avatar · gear must fit on one line at 360px */
.app-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: 0 0 auto;
}
.icon-btn:active { background: var(--surface-2); transform: scale(0.92); }
.icon-btn svg { width: 24px; height: 24px; }
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.avatar span, .avatar.big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
}
.avatar:active { transform: scale(0.92); }
.avatar.big { width: 48px; height: 48px; font-size: 20px; flex: 0 0 auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;                     /* spec A-49 touch target */
  padding: 0 10px 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  max-width: calc(100vw - 260px);   /* spec A-50 (v3: the ☆ favourites button sits left of it) */
  min-width: 84px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;                   /* v3: the title gives way first; the status stays readable */
  transition: transform 0.15s ease;
}
/* v3.1: on a store tab the arrange toggle takes another 44px. On a phone the title gives its
   room up (an ellipsised "S…" says nothing) so the Alexa status stays readable at 360px. */
.header-row:has(#btnArrange:not([hidden])) .pill { max-width: calc(100vw - 340px); }
@media (max-width: 480px) {
  /* visually hidden, still the page's h1 for assistive tech; the ☆ button takes over as the spacer */
  .header-row:has(#btnArrange:not([hidden])) .app-title {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .header-row:has(#btnArrange:not([hidden])) #btnFavourites { margin-left: auto; }
  .header-row:has(#btnArrange:not([hidden])) .pill { max-width: calc(100vw - 236px); }
}
#btnArrange[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.pill:active { transform: scale(0.95); }
.pill-text { overflow: hidden; text-overflow: ellipsis; }
.pill-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--off);
  flex: 0 0 auto;
}
.pill.ok .pill-dot, .status-box.ok .pill-dot { background: var(--ok); }
.pill.ok { color: var(--ok); }
.pill.busy .pill-dot, .status-box.busy .pill-dot { background: var(--busy); animation: pulse 1.2s ease-in-out infinite; }
.pill.busy { color: var(--busy); }
.pill.warn .pill-dot, .status-box.warn .pill-dot { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.pill.warn { color: var(--warn); }
@media (prefers-color-scheme: light) {
  .pill.warn { color: color-mix(in srgb, var(--warn) 70%, #000); } /* 13px text on surface-2 needs 4.5:1 */
}
.pill.err .pill-dot, .status-box.err .pill-dot { background: var(--danger); }
.pill.err { color: var(--danger); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- tabs ---------- */
.tabs-row { display: flex; align-items: center; }
.tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 8px;
  padding: 2px var(--gutter) 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs-row > .icon-btn { margin: 0 6px 6px 0; }
.tab {
  flex: 0 0 auto;
  height: 44px;                     /* spec A-49 */
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 0.12s ease, background 0.15s ease;
}
.tab:active { transform: scale(0.95); }
.tab.selected {
  background: var(--tab-c, var(--accent));
  border-color: var(--tab-c, var(--accent));
  color: var(--tab-fg, #fff);       /* white or dark ink, whichever reads on the store colour */
}
.tab .badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tab.selected .badge {
  background: color-mix(in srgb, var(--tab-fg, #fff) 22%, transparent);
  color: var(--tab-fg, #fff);
}
.tab .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tab-c, var(--accent));
}
.tab.selected .swatch { background: var(--tab-fg, #fff); }

/* status strip: "Checking for changes…" / "Offline — …" / "2 changes waiting to sync" */
.strip {
  font-size: 13px;
  font-weight: 600;
  padding: 6px var(--gutter);
  background: var(--surface-2);
  color: var(--muted);
  border-top: 1px solid var(--border);
  text-align: center;
  line-height: 1.3;                 /* wraps on a phone: "N changes waiting to sync" must stay visible */
  overflow-wrap: anywhere;
}
.strip.offline { background: var(--warn); color: #1b1200; border-top-color: var(--warn); }
.strip.pending:not(.offline) { color: var(--accent); }

/* ---------- content / list ---------- */
.content {
  padding: 8px var(--gutter) calc(var(--addbar-h) + 24px);
  min-height: 60vh;
}
html.kb-open .content { padding-bottom: calc(var(--addbar-h) + var(--kb-offset) + 24px); }
.list { display: flex; flex-direction: column; gap: 14px; }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.section-head .count {
  font-weight: 600;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
}
.section-head .btn.small { margin-left: auto; }
.rows { list-style: none; margin: 0; padding: 0; }

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--row-h);
  padding: 4px 4px 4px 8px;
  border-top: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;   /* no iOS text callout on long-press */
  touch-action: pan-y;
  transition: transform 0.12s ease, background 0.2s ease;
  position: relative;
}
.row:first-child { border-top: 0; }
.row.bump { transform: scale(0.975); background: var(--surface-2); }
.row.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.check {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.check-circle {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s cubic-bezier(.2,1.6,.4,1);
}
.check-circle svg {
  width: 16px; height: 16px;
  transform: scale(0);
  transition: transform 0.22s cubic-bezier(.2,1.6,.4,1);
}
.row.checked .check-circle { background: var(--ok); border-color: var(--ok); transform: scale(1.05); }
.row.checked .check-circle svg { transform: scale(1); }

.row-main { flex: 1 1 auto; min-width: 0; padding: 6px 0; }
.row-text {
  font-size: 17px;
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: color 0.25s ease;
}
.row-text::after {
  content: "";
  position: absolute;
  left: 0; top: 55%;
  height: 2px;
  width: 0;
  background: currentColor;
  transition: width 0.28s ease;
}
.row.checked .row-text { color: var(--muted); }
.row.checked .row-text::after { width: 100%; }
.row-text .qty { font-weight: 700; color: var(--accent); margin-right: 2px; }
.row.checked .row-text .qty { color: var(--muted); }
/* clock badge on rows whose change is still queued (spec A-33) */
.pending-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: -2px;
  margin-left: 6px;
  color: var(--warn);
}
.pending-badge svg { width: 15px; height: 15px; }
.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
.row-meta .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.row-meta .src { opacity: 0.8; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  --c: var(--accent);
  color: var(--c);
  color: color-mix(in srgb, var(--c) 40%, var(--text));   /* any store colour stays readable as 11px text (>= 4.4:1) */
  background: var(--accent-soft);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  /* store brand colours are mostly dark blues: lift them so chips/swatches stay readable on dark surfaces */
  .chip { background: color-mix(in srgb, var(--c) 30%, transparent); }
  .tab .swatch { background: color-mix(in srgb, var(--tab-c, var(--accent)) 60%, #fff); }
  .toggle-chip.on { border-color: color-mix(in srgb, var(--c) 55%, #fff); }
}
.more {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border: 0; background: transparent;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.more svg { width: 22px; height: 22px; }
.more:active { background: var(--surface-2); }

.trolley .section-head { color: var(--ok); }
.trolley .row-text { color: var(--muted); }

.empty {
  text-align: center;
  padding: 56px 20px 30px;
  color: var(--muted);
}
.empty .big { font-size: 42px; margin-bottom: 10px; }
.empty h2 { font-size: 20px; color: var(--text); font-weight: 700; margin-bottom: 6px; }
.empty p { font-size: 14px; }

/* skeleton */
.skeleton { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.sk-head, .sk-row {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk-head { height: 16px; width: 40%; margin-top: 8px; }
.sk-row { height: var(--row-h); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- add bar ---------- */
.addbar {
  position: fixed;
  left: 0; right: 0; bottom: var(--kb-offset);
  z-index: 25;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px var(--gutter) calc(10px + var(--safe-bottom));
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.06);
}
/* spec A-49: chips keep their look; the hit area grows 7px above and below (the containers
   get the same padding so the overflow strip does not clip it) */
.add-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 7px 0 8px;
  min-height: 44px;
}
.add-chips::-webkit-scrollbar { display: none; }
.toggle-chip {
  flex: 0 0 auto;
  position: relative;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  --c: var(--accent);
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}
.toggle-chip::before { content: ""; position: absolute; inset: -7px 0; }
.toggle-chip:active { transform: scale(0.94); }
.toggle-chip.on {
  background: var(--c);
  border-color: var(--c);
  color: var(--fg, #fff);           /* set per chip by inkOn() */
}
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; padding: 7px 0; }
.chip-group .toggle-chip { height: 36px; font-size: 14px; }
.add-row { display: flex; gap: 8px; align-items: center; }
.add-input {
  flex: 1 1 auto;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 18px;
  font-size: 16px;
  min-width: 0;
  outline: none;
}
.add-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-btn {
  flex: 0 0 48px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease;
}
.add-btn:active { transform: scale(0.9); }
.add-btn svg { width: 24px; height: 24px; }
.add-btn:disabled { opacity: 0.5; }

/* ---------- sheets ---------- */
.backdrop {
  position: fixed; inset: 0;
  z-index: 40;
  background: rgba(10, 16, 24, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  max-height: calc(100vh - 24px - var(--safe-top));
  max-height: calc(100dvh - 24px - var(--safe-top));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.2,.9,.3,1);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 720px;
}
.sheet.show { transform: translateY(0); }
.sheet-handle {
  width: 40px; height: 5px;
  border-radius: 3px;
  background: var(--border);
  margin: 8px auto 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px var(--gutter);
}
.sheet-header h2 { font-size: 19px; font-weight: 700; }
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px var(--gutter) calc(20px + var(--safe-bottom) + var(--kb-offset));
  -webkit-overflow-scrolling: touch;
}
.sub { font-size: 15px; font-weight: 700; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1 1 0; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select {
  height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 12px;
  font-size: 16px;
  width: 100%;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input:disabled, .field select:disabled { opacity: 0.6; }
.field-row { display: flex; gap: 12px; }
.colour-field { flex: 0 0 90px; }
.field input[type="color"] { padding: 4px; }
.field-meta { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }
.hint { font-size: 13px; color: var(--muted); }
.hint code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.form-error { font-size: 14px; font-weight: 600; color: var(--danger); margin: -4px 0 12px; overflow-wrap: anywhere; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn-row.wrap { flex-wrap: wrap; justify-content: flex-start; margin: 12px 0; }
.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.12s ease, opacity 0.15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.wide { width: 100%; }
/* spec A-49: 36px look, 44px+ hit area */
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; position: relative; }
.btn.small::before { content: ""; position: absolute; inset: -5px 0; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input {
  flex: 1 1 auto; min-width: 0;
  height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); padding: 0 12px; font-size: 16px;
}

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 48px; margin-bottom: 10px; gap: 12px;
}
.switch {
  appearance: none; -webkit-appearance: none;
  width: 50px; height: 30px; border-radius: 999px;
  background: var(--border);
  position: relative; margin: 0; flex: 0 0 auto;
  transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* alexa status */
.status-box {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.status-line { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.status-detail { font-size: 13px; color: var(--muted); margin-top: 4px; }
.status-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  margin: 10px 0 0; font-size: 13px;
}
.status-grid dt { color: var(--muted); }
.status-grid dd { margin: 0; }
.status-error {
  margin-top: 10px; font-size: 13px; color: var(--danger);
  overflow-wrap: anywhere;
}
.callout {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  border: 1px solid var(--border);
}
.callout.warn { background: var(--surface-2); border-color: var(--warn); }
@supports (background: color-mix(in srgb, red 10%, white)) {
  .callout.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
}
.failed-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.failed-list:empty { display: none; }
.failed-list li { overflow-wrap: anywhere; }
.shot { display: block; width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-top: 8px; background: var(--surface-2); }
.shot-wrap { margin-bottom: 12px; }
.shot-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* aisle order editor (stores manager) */
.section-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.section-item { display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 4px 4px 4px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.section-item:first-child { border-top: 0; }
.section-item .idx { width: 22px; font-size: 12px; color: var(--muted); font-weight: 700; flex: 0 0 auto; }
.section-item input { flex: 1 1 auto; min-width: 0; height: 44px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 0 8px; font-size: 15px; } /* spec A-49 */
.section-item input:focus { border-color: var(--accent); background: var(--bg); outline: none; }
.section-item .icon-btn { width: 44px; height: 44px; }
.section-item .icon-btn:disabled { opacity: 0.25; }
.section-item .cats { font-size: 11px; color: var(--muted); padding-left: 8px; }
.sheet-body > .hint { margin-bottom: 12px; }

/* account sheet */
.user-head { display: flex; align-items: center; gap: 14px; padding: 6px 0 16px; }
.user-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-names strong { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-list .btn { width: 100%; justify-content: flex-start; }
#userMenuExtra:empty { display: none; }   /* members have no extra entries: no double gap */
.confirm-panel { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--danger); font-size: 14px; }
.confirm-body { font-size: 16px; margin: 6px 0 16px; }

/* ---------- auth layer (login / first account / change password / unreachable) ---------- */
.auth-layer {
  position: fixed; inset: 0;
  z-index: 55;
  background: rgba(10, 16, 24, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--gutter) + var(--safe-top)) var(--gutter) calc(var(--gutter) + var(--safe-bottom));
  overflow-y: auto;
}
.card {
  width: 100%;
  max-width: 420px;
  margin: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px calc(18px + var(--kb-offset));
}
.card h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.card > .hint { margin-bottom: 16px; }
.card-logo { font-size: 38px; line-height: 1; margin-bottom: 10px; color: var(--accent); }
.card-logo svg { width: 40px; height: 40px; }

/* toasts */
.toasts {
  position: fixed;
  left: 50%; bottom: calc(var(--addbar-h) + var(--kb-offset) + 10px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
  width: calc(100% - 2 * var(--gutter));
  max-width: 480px;
}
.toast {
  border: 0;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.action { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 24px; }
.toast.action .toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.toast-btn {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  font-weight: 700;
  position: relative;
}
.toast-btn::before { content: ""; position: absolute; inset: -6px 0; }
@media (prefers-color-scheme: light) {
  .toast:not(.error):not(.ok) .toast-btn { background: rgba(255, 255, 255, 0.2); color: #fff; }
}
@media (prefers-color-scheme: dark) {
  /* the toast is light here: a white wash would vanish, so the button gets a dark one and an edge */
  .toast:not(.error):not(.ok) .toast-btn { background: rgba(15, 23, 32, 0.12); border: 1px solid rgba(15, 23, 32, 0.35); }
}
.toast-btn:disabled { opacity: 0.6; }

@media (min-width: 720px) {
  .content, .header-row, .select-bar, .tabs-row, .strip, .addbar, .actionbar { max-width: 720px; margin-left: auto; margin-right: auto; }
  .addbar, .actionbar { left: 50%; right: auto; width: 100%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}
@media (hover: hover) {
  .row:hover { background: var(--surface-2); }
  .icon-btn:hover, .more:hover { color: var(--text); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- ⋯ menu (spec A-48: a sibling of the tabs strip, never inside it) ---------- */
.tabs-row { position: relative; }
.menu-pop {
  position: absolute;
  top: calc(100% - 2px);
  right: 10px;
  z-index: 30;
  min-width: 230px;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.menu-item {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-align: left;
  display: block;                   /* text-overflow has no effect on a flex container's text */
  line-height: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-item:active, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item:disabled { opacity: 0.45; cursor: default; }
.menu-item.danger { color: var(--danger); }

/* ---------- select mode (spec A-44) ---------- */
.select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--gutter) 4px;
  min-height: 56px;
}
.select-count {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn.small.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
body.select-mode .header-row, body.select-mode .addbar, body.select-mode .row .more, body.select-mode .handle { display: none !important; }
body.select-mode .check-circle { border-radius: 8px; }
/* in select mode the box shows selection, not the ticked state */
body.select-mode .row.checked:not(.selected) .check-circle { background: transparent; border-color: var(--muted); transform: none; }
body.select-mode .row.checked:not(.selected) .check-circle svg { transform: scale(0); }
.row.selected { background: var(--accent-soft); }
.row.selected .check-circle { background: var(--accent); border-color: var(--accent); }
.row.selected .check-circle svg { transform: scale(1); }
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px var(--gutter) calc(10px + var(--safe-bottom));
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.06);
}
.actionbar .btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 14px; white-space: nowrap; }

/* ---------- stores manager ---------- */
.store-list, .member-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.store-item, .member-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 4px 6px 4px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.store-item:first-child, .member-item:first-child { border-top: 0; }
.store-item.flash, .member-item.flash { animation: flash 1.2s ease-out; }
.store-item .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--accent)); flex: 0 0 auto; margin-right: 4px; }
.store-main, .member-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.store-main strong, .member-main strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-main .hint, .member-main .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.store-item .icon-btn:disabled { opacity: 0.25; }
.store-item .btn.small { margin-left: 4px; }
.editor-top { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.editor-top h3 { font-size: 17px; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colour-pick { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.swatch-btn {
  width: 44px; height: 44px;
  border: 0; padding: 0;
  background: transparent;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.swatch-btn::after {
  content: "";
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
  transition: transform 0.12s ease;
}
.swatch-btn:active::after { transform: scale(0.9); }
.swatch-btn[aria-pressed="true"]::after { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
/* these sit inside .field, whose generic input rule must not size them */
.colour-pick .swatch-native { width: 44px; height: 44px; padding: 7px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; box-shadow: none; }
.alias-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: text;
}
.alias-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.alias-chips { display: contents; }
.alias-chip {
  position: relative;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.alias-chip::before { content: ""; position: absolute; inset: -7px 0; }   /* spec A-49 hit area */
.alias-chip .x { color: var(--muted); font-size: 17px; line-height: 1; }
.alias-box .alias-input { flex: 1 1 120px; width: auto; min-width: 100px; height: 30px; border: 0; background: transparent; padding: 0 4px; font-size: 16px; outline: none; box-shadow: none; }
.field .form-error { margin: 6px 0 0; }

/* ---------- household members ---------- */
.member-item { gap: 12px; min-height: 64px; }
.member-item.open { background: var(--surface-2); }
.member-panel { padding: 10px 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.member-panel .btn-row { justify-content: flex-start; flex-wrap: wrap; margin-top: 0; }
.member-panel .confirm-panel { margin-top: 0; background: var(--surface); }
.member-panel .confirm-panel .btn-row { justify-content: flex-end; margin-top: 8px; }
.member-panel .confirm-panel p { margin-bottom: 10px; }
.member-panel .field { margin-bottom: 10px; }
.role-field { flex: 0 0 120px; }

/* ---------- v3: branches, interleaved view, arrange mode ---------- */
/* a store tab walked with a branch layout: the branch name on a small second line */
.tab-label { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.tab-branch { font-size: 11px; font-weight: 600; opacity: 0.8; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the ⋯ menu's ticked entry ("Interleaved view") */
.menu-item.check-item { position: relative; padding-right: 36px; }
.menu-item.check-item[aria-checked="true"]::after {
  content: "✓"; position: absolute; right: 14px; top: 0; color: var(--accent); font-weight: 800;
}

/* interleaved view: one header-less group; each row names its section */
.section.interleaved .rows { padding-top: 2px; }
.section-chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap;
}

/* arrange mode: the toolbar replaces the tabs row; rows and headers get 44x44 handles */
.arrange-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px var(--gutter) 8px; min-height: 52px;
}
.arrange-title {
  flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 14px; line-height: 1.2;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.btn.small.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
body.arrange-mode .tabs-row, body.arrange-mode .addbar { display: none !important; }
.handle {
  flex: 0 0 44px; width: 44px; height: 44px;
  border: 0; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  touch-action: pan-y;             /* v3.1: always on screen, so a swipe on ≡ still scrolls; a drag needs a hold first */
  cursor: grab;
}
body.arrange-mode .handle { touch-action: none; } /* arrange mode: the drag owns the gesture at once (spec v3) */
.handle svg { width: 22px; height: 22px; }
.handle:active { background: var(--surface-2); cursor: grabbing; }
.handle:focus-visible { outline: none; box-shadow: var(--focus); }
.section-head .section-handle { margin: -8px 0 -8px -10px; }
/* v3.1: arrange mode — hide an aisle at this layout, and the "Hidden aisles" list to show it again */
.section-head .section-hide { width: 44px; height: 44px; margin: -10px -10px -10px 0; }
.section-head .section-hide svg { width: 20px; height: 20px; }
.section.hidden-aisles { border-style: dashed; }
.hidden-aisle {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 8px 4px 14px;
  border-top: 1px solid var(--border); color: var(--muted);
}
.hidden-aisle-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.hidden-aisle .btn { flex: 0 0 auto; min-height: 44px; }
.section-head .section-name { flex: 1 1 auto; min-width: 0; }
body.arrange-mode .row { cursor: default; }
body.arrange-mode .row .more { visibility: hidden; }   /* ticked rows are not arranged; their ⋯ would do nothing */
.row.dragging, .section.dragging { opacity: 0.35; }
/* an aisle with no open items, shown only while arranging so a row can be dropped into it */
.drop-placeholder {
  display: flex; align-items: center; min-height: 44px; padding: 0 14px;
  border-top: 1px dashed var(--border); color: var(--muted); font-size: 13px;
}
.drag-ghost {
  position: fixed; z-index: 60; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 17px; overflow: hidden; white-space: nowrap;
}
.drag-ghost.section { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.drag-ghost .drag-grip { color: var(--accent); display: inline-flex; }
.drag-ghost .drag-grip svg { width: 20px; height: 20px; }
.drag-ghost .drag-label { overflow: hidden; text-overflow: ellipsis; }
.drop-line {
  position: fixed; z-index: 59; height: 2px; pointer-events: none;
  background: var(--accent); border-radius: 2px;
}

/* Branches sheet */
.branches-store { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.branch-list, .choice-list {
  list-style: none; margin: 12px 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.branch-item {
  display: flex; align-items: center; gap: 6px; min-height: 56px;
  padding: 4px 8px 4px 4px; border-top: 1px solid var(--border); background: var(--surface);
}
.branch-item:first-child, .choice-list li:first-child { border-top: 0; }
.branch-item.editing { background: var(--surface-2); padding-left: 12px; }
.branch-item.editing > .branch-name { flex: 1 1 auto; font-weight: 600; }
.branch-pick { flex: 1 1 auto; min-width: 0; min-height: 48px; display: flex; align-items: center; gap: 10px; padding-left: 8px; cursor: pointer; }
.branch-pick input[type="radio"] { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
.branch-pick .branch-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-pick .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-edit { flex: 1 1 auto; min-width: 0; }
.branch-edit input {
  width: 100%; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 0 12px; font-size: 16px;
}
.branch-edit .form-error { margin: 4px 0 0; }
#addBranchForm + .form-error { margin-top: 8px; }

/* Section… sheet (select mode) */
.choice-list li { border-top: 1px solid var(--border); }
.choice-list .section-choice {
  width: 100%; min-height: 48px; border: 0; border-radius: 0; background: var(--surface);
  justify-content: flex-start; padding: 0 16px; text-align: left;
}
.choice-list .section-choice:active { background: var(--surface-2); }

/* store editor: per-aisle "Shown" switch (the default layout's hidden list) and Branches… */
.section-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shown-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 12px; font-weight: 600; color: var(--muted); padding-right: 4px; flex: 0 0 auto; }
.section-item .shown-toggle input.switch, .field .shown-toggle input.switch {
  width: 50px; height: 30px; padding: 0; border: 0; border-radius: 999px; flex: 0 0 auto;
  background: var(--border);
}
.section-item .shown-toggle input.switch:checked, .field .shown-toggle input.switch:checked { background: var(--ok); }
.section-item .shown-toggle input.switch:focus-visible { box-shadow: var(--focus); }
.btn-row.start { justify-content: flex-start; margin-top: 0; }
/* five actions since v3 ("Section…"): they must fit a 360px phone */
.actionbar { gap: 6px; }
.actionbar .btn { padding: 0 2px; font-size: 13px; overflow: hidden; }
.section-sub .cats { flex: 1 1 auto; min-width: 0; }

/* ---------- v3: photos ---------- */
/* row thumbnail: a 44px target holding the 40px square photo */
.thumb {
  flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 10px;
  -webkit-touch-callout: none;
}
.thumb-img, .fav-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block;
  background: var(--surface-2); flex: 0 0 auto;
}
.thumb:active { transform: scale(0.94); }
.row.checked .thumb-img { opacity: 0.55; }
body.select-mode .thumb { pointer-events: none; }

.photo-block { display: flex; align-items: center; gap: 12px; }
.photo-preview { position: relative; flex: 0 0 72px; width: 72px; height: 72px; }
.photo-thumb { width: 72px; height: 72px; padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: block; }
.photo-thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder {
  width: 72px; height: 72px; border-radius: var(--radius-sm); border: 1.5px dashed var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--bg);
}
.photo-placeholder svg { width: 28px; height: 28px; }
.photo-spinner {
  position: absolute; inset: 0; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }

.photo-viewer {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: calc(56px + var(--safe-top)) 8px calc(16px + var(--safe-bottom));
  opacity: 0; transition: opacity 0.18s ease;
  cursor: zoom-out;
}
.photo-viewer.show { opacity: 1; }
.photo-viewer-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-viewer-close {
  position: absolute; top: calc(6px + var(--safe-top)); right: 8px;
  color: #fff; background: rgba(255, 255, 255, 0.14);
}
.photo-viewer-close:active { background: rgba(255, 255, 255, 0.28); }
body.viewer-open { overflow: hidden; }

/* ---------- v3: favourites ---------- */
.sheet.full { height: calc(100vh - 24px - var(--safe-top)); height: calc(100dvh - 24px - var(--safe-top)); }
.sheet.full .sheet-body { flex: 1 1 auto; }
.sheet-header .btn.small { white-space: nowrap; flex: 0 0 auto; }
.sheet-header .btn.small + h2 { flex: 1 1 auto; margin-left: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-row.center { justify-content: center; }
.btn .btn-icon { width: 18px; height: 18px; flex: 0 0 auto; }
#editFavourite.is-favourite { color: var(--accent); }
#editFavourite.is-favourite .btn-icon { fill: currentColor; }

/* v3.1: "Add a favourite" comes first; search sits below it (two different fields at 360px) */
.fav-new { display: flex; gap: 8px; align-items: center; margin: 2px 0 10px; }
.fav-new-input {
  flex: 1 1 auto; min-width: 0; height: 48px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--accent); background: var(--surface); color: var(--text); padding: 0 12px; font-size: 16px; outline: none;
}
.fav-new-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.fav-new .btn { flex: 0 0 auto; min-height: 48px; min-width: 64px; }
.fav-tools { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.fav-search {
  flex: 1 1 auto; min-width: 0; height: 44px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 0 12px; font-size: 16px; outline: none;
}
.fav-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fav-list {
  list-style: none; margin: 0 0 12px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.fav-row {
  display: flex; align-items: center; gap: 2px; min-height: 56px; padding-right: 4px;
  border-top: 1px solid var(--border); background: var(--surface);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.fav-row:first-child { border-top: 0; }
.fav-row.selected { background: var(--accent-soft); }
.fav-main {
  flex: 1 1 auto; min-width: 0; min-height: 56px; border: 0; background: transparent; color: var(--text);
  display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 10px; text-align: left;
}
.fav-main:active { background: var(--surface-2); }
.fav-thumb.placeholder { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.fav-thumb.placeholder svg { width: 20px; height: 20px; }
.fav-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.fav-text { font-size: 16px; overflow-wrap: anywhere; }
.fav-text .qty { font-weight: 700; color: var(--accent); margin-right: 2px; }
.fav-row .row-meta .note { max-width: 50vw; }
.on-list { font-style: italic; color: var(--muted); }
.fav-check { flex: 0 0 auto; }
.fav-row.selected .check-circle { background: var(--accent); border-color: var(--accent); }
.fav-row.selected .check-circle svg { transform: scale(1); }
.fav-none { margin: 8px 0 12px; }
.fav-empty { padding: 32px 12px; }
.fav-more { margin-top: 0; }
.fav-selectbar {
  position: sticky; bottom: calc(-20px - var(--safe-bottom) - var(--kb-offset));
  padding: 10px 0 calc(10px + var(--safe-bottom)); background: var(--surface);
}
.memory-item { border-top: 1px solid var(--border); }
.memory-item:first-child { border-top: 0; }
.memory-loading { padding: 14px 12px; }
.memory-pick { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; cursor: pointer; }
.memory-pick input[type="checkbox"] { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
.memory-pick .memory-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.memory-pick .hint { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
#favEditor .confirm-panel { margin: 0 0 12px; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .photo-viewer { transition: none; }
}
