*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root, :root[data-theme="light"] {
  --primary: #7c3aed;
  --primary-light: #8b5cf6;
  --primary-dark: #6d28d9;
  --primary-faint: #f5f3ff;
  --success: #059669;
  --success-light: #d1fae5;
  --success-text: #065f46;
  --danger: #dc2626;
  --danger-faint: #fee2e2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --bg: #f4f4f8;
  --bg-subtle: #ececf0;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e4e4e7;
  --border-strong: #d1d5db;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --toast-bg: #18181b;
  --toast-text: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);
  --shadow-fab: 0 6px 20px rgba(124,58,237,.45);
}

:root[data-theme="dark"] {
  --primary: #a78bfa;
  --primary-light: #8b5cf6;
  --primary-dark: #c4b5fd;
  --primary-faint: #2a2150;
  --success: #34d399;
  --success-light: #0c3a2c;
  --success-text: #6ee7b7;
  --danger: #f87171;
  --danger-faint: #3a1414;
  --warning: #fbbf24;
  --warning-light: #3a2e10;
  --bg: #0e0e13;
  --bg-subtle: #16161d;
  --surface: #1b1b23;
  --surface-2: #21212b;
  --border: #2e2e3a;
  --border-strong: #41414f;
  --text: #ececf1;
  --text-muted: #a1a1aa;
  --text-faint: #6b6b76;
  --toast-bg: #2e2e3a;
  --toast-text: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 2px 8px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.6), 0 4px 8px rgba(0,0,0,.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 60%, #6d28d9 100%);
  color: white;
  padding: 14px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(109,40,217,.3);
}

.header-left { display: flex; flex-direction: column; gap: 1px; }
header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
}
.header-subtitle {
  font-size: .72rem;
  opacity: .7;
  font-weight: 400;
  letter-spacing: .02em;
}

.header-actions { display: flex; gap: 6px; }
.icon-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: background .15s, transform .1s;
  backdrop-filter: blur(4px);
}
.icon-btn:hover { background: rgba(255,255,255,.25); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.store-active {
  background: white;
  border-color: white;
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}

/* ── Main ── */
main {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 96px; /* space for FAB */
}

/* ── View toggle ── */
#view-toggle {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.view-btn {
  flex: 1; padding: 7px 4px;
  border: none; border-radius: 8px;
  cursor: pointer; font-size: .76rem; font-weight: 600;
  background: transparent; color: var(--text-muted);
  transition: all .18s; font-family: inherit;
  letter-spacing: -.02em;
  /* Four modes have to share one phone-width row — never let a label wrap. */
  white-space: nowrap;
}
.view-btn.active {
  background: var(--primary-faint);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* ── Category section label ── */
.category-label {
  margin-top: 6px;
  font-size: .75rem;
  color: var(--primary-dark);
}
.cat-icon { margin-right: 4px; }

/* Second grouping level (category inside a store): stepped in and quieter, so the
   store above it stays the heading you scan for. */
.section-label.sub-label {
  margin-top: 2px;
  padding-left: 16px;
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--text-faint);
  opacity: .85;
}
.section-label.sub-label::after { opacity: .5; }
.section-label.sub-label .cat-icon { font-size: .82em; }

/* Small explanatory line under a form field (e.g. where a default came from) */
.field-hint {
  margin-top: 5px;
  font-size: .74rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.field-hint:empty { display: none; }

/* ── List ── */
#list-container { display: flex; flex-direction: column; gap: 8px; }

.list-item {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s, opacity .25s;
}
.list-item:not(.checked):hover { box-shadow: var(--shadow-lg); border-color: var(--border); }
.list-item.checked { opacity: .5; }
.list-item.checked .item-name { text-decoration: line-through; color: var(--text-muted); }

/* ── Swipe action backgrounds ── */
.swipe-bg { position: absolute; inset: 0; pointer-events: none; }
.swipe-check-hint,
.swipe-edit-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center;
  opacity: 0;
  font-size: .85rem; font-weight: 700; gap: 8px;
}
.swipe-check-hint { background: var(--success); color: white; padding-left: 22px; }
.swipe-edit-hint  { background: var(--primary); color: white; padding-right: 22px; justify-content: flex-end; }

/* ── Swipe content wrapper (carries the surface background that slides) ── */
.swipe-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  position: relative;
  z-index: 1;
  will-change: transform;
}
.swipe-content::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary-light);
  border-radius: 4px 0 0 4px;
  opacity: 0;
  transition: opacity .2s;
}
.list-item:not(.checked):hover .swipe-content::before { opacity: 1; }

/* Custom checkbox */
.item-check {
  width: 26px; height: 26px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
  background: transparent;
  font-size: 0;
  position: relative;
}
.item-check::after {
  content: '';
  width: 10px; height: 6px;
  border-left: 2.5px solid white;
  border-bottom: 2.5px solid white;
  transform: rotate(-45deg) scale(0);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
  margin-top: -2px;
}
.item-check:hover { border-color: var(--primary); transform: scale(1.1); }
.list-item.checked .item-check {
  background: var(--success);
  border-color: var(--success);
  transform: scale(1);
}
.list-item.checked .item-check::after { transform: rotate(-45deg) scale(1); }

.item-body { flex: 1; min-width: 0; }
.item-name {
  font-size: .975rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.item-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .68rem; padding: 2px 7px; border-radius: 99px;
  font-weight: 600; letter-spacing: .01em;
}
.badge-grocy { background: var(--primary-faint); color: var(--primary-dark); }
.badge-barcode { background: var(--warning-light); color: var(--warning); }
.badge-local { background: #f1f5f9; color: #64748b; }
.badge-store { background: #e0f2fe; color: #0369a1; }

.item-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.item-qty {
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}
.item-delete {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 6px; border-radius: 8px; font-size: .9rem;
  opacity: 0; transition: opacity .15s, color .15s, background .15s;
  line-height: 1;
}
.list-item:hover .item-delete { opacity: 1; }
.item-delete:hover { color: var(--danger); background: var(--danger-faint); }

/* Mobile: always show delete */
@media (hover: none) {
  .item-delete { opacity: 0.4; }
}

.section-label {
  font-size: .72rem; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .1em;
  padding: 12px 4px 4px;
  display: flex; align-items: center; gap: 8px;
}
.section-label::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}

/* ── FAB ── */
#fab {
  position: fixed;
  bottom: 24px; right: 24px;
  height: 56px;
  padding: 0 24px 0 18px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  display: flex; align-items: center; gap: 8px;
  transition: transform .15s, box-shadow .15s;
  z-index: 20;
  letter-spacing: -.01em;
}
#fab .fab-icon { font-size: 1.4rem; line-height: 1; }
#fab:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(124,58,237,.55); }
#fab:active { transform: scale(.96); }

/* ── Overlay ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 30;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.overlay.open { opacity: 1; pointer-events: auto; }

/* ── Sheet ── */
.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 40;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,0,.15,1), bottom .1s linear;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 32px rgba(0,0,0,.12);
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.sheet-header {
  padding: 14px 20px 0;
  flex-shrink: 0;
}
.sheet-title {
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.sheet-footer {
  flex-shrink: 0;
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
/* safe area for iOS home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sheet-footer { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ── Modal ── */
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(.96);
  background: var(--surface);
  border-radius: var(--radius);
  z-index: 40;
  width: min(500px, calc(100vw - 32px));
  opacity: 0;
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal.open { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }

.modal-header {
  padding: 20px 24px 0;
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: -.02em;
}
.modal-body {
  flex: 1; overflow-y: auto;
  padding: 16px 24px;
}
.modal-footer {
  flex-shrink: 0;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--border);
}

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
label {
  display: block; font-size: .8rem; font-weight: 600;
  margin-bottom: 6px; color: var(--text-muted);
  letter-spacing: .02em; text-transform: uppercase;
}
input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .975rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}
textarea { resize: vertical; min-height: 60px; }

/* ── Checkbox list (store pickers) ── */
.check-list {
  max-height: 168px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 4px;
}
.check-list .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
}
.check-list .check-row:hover { background: var(--surface-2); }
.check-list .check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  border-radius: 5px;
  accent-color: var(--primary);
  cursor: pointer;
}
.check-list .field-hint { padding: 9px 10px; }

/* The main store, chosen by long-pressing a row. The badge only appears on
   that one row; the name stays put so the list does not jump while pressing. */
.check-list .check-row .main-badge {
  display: none;
  margin-left: auto;
  flex-shrink: 0;
  font-style: normal;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary, #fff);
}
.check-list .check-row.is-main .main-badge { display: inline-block; }
.check-list .check-row.is-main { background: var(--surface-2); }
/* Nothing here should be selectable — a long press otherwise starts the
   browser's own text selection instead of picking a main store. */
.check-list .check-row {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.search-wrap { position: relative; }
.search-wrap input { padding-left: 42px; font-size: 1rem; }
.search-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%); color: var(--text-faint);
  font-size: 1rem; pointer-events: none;
}

/* ── Suggestions ── */
#product-suggestions {
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 16px rgba(0,0,0,.08);
}
#product-suggestions.open { display: block; }
.suggestion-item {
  padding: 11px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  font-size: .95rem;
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--primary-faint); }
.suggestion-item .s-name { flex: 1; font-weight: 500; }
.suggestion-item .s-group {
  font-size: .75rem; color: var(--text-faint);
  background: var(--bg); padding: 1px 7px; border-radius: 99px;
}
.suggestion-new { color: var(--primary); }
.suggestion-new .s-name { font-weight: 600; }

/* ── Buttons ── */
.btn {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit;
  letter-spacing: -.01em;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(124,58,237,.3);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(124,58,237,.45); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-secondary.active { background: var(--primary); color: white; border-color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-faint); }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 7px 14px; font-size: .83rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; justify-content: center; }

/* ── Sync toggle ── */
.sync-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  border: 1.5px solid var(--border);
}
.sync-toggle button {
  flex: 1; padding: 9px 8px; border: none; border-radius: 7px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
  background: transparent; color: var(--text-muted);
  transition: all .18s; font-family: inherit;
}
.sync-toggle button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Wizard ── */
.wizard-steps { display: flex; gap: 5px; margin-bottom: 18px; }
.wizard-step-dot {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--border);
  transition: background .25s, transform .15s;
}
.wizard-step-dot.done { background: var(--success); }
.wizard-step-dot.active { background: var(--primary); transform: scaleY(1.3); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--toast-bg); color: var(--toast-text);
  padding: 10px 18px; border-radius: 10px;
  font-size: .88rem; font-weight: 500;
  z-index: 100;
  opacity: 0; transition: all .22s cubic-bezier(.34,1.56,.64,1);
  white-space: normal;
  max-width: calc(100vw - 24px);
  display: inline-flex; align-items: center; justify-content: center;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.has-action { pointer-events: auto; }
#toast.has-action .toast-undo { pointer-events: auto; }

/* ── Grocy prompt ── */
#grocy-prompt {
  position: fixed;
  bottom: 90px; left: 12px; right: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  z-index: 50;
  transform: translateY(140px);
  opacity: 0;
  transition: transform .32s cubic-bezier(.34,1.56,.64,1), opacity .22s;
  border: 1px solid var(--border);
  overflow: hidden;
}
#grocy-prompt::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, var(--primary), var(--primary-dark));
}
#grocy-prompt.show { transform: translateY(0); opacity: 1; }
#grocy-prompt-text { flex: 1; padding-left: 4px; }
#grocy-prompt-name { display: block; font-weight: 700; font-size: .95rem; }
#grocy-prompt-hint { display: block; font-size: .78rem; color: var(--text-muted); margin-top: 1px; }
.prompt-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Checkoff sheet ── */
.checkoff-section {
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.checkoff-section h3 {
  font-size: .88rem; font-weight: 700;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 7px;
  color: var(--text);
}
.checkoff-section h3 .section-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
}
.icon-barcode { background: var(--warning-light); }
.icon-price { background: var(--success-light); }

/* ── Variant picker ── */
.variant-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.variant-chip {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: .9rem;
  text-align: left;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.variant-chip.selected {
  border-color: var(--primary);
  background: var(--primary-faint);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ── Price calc display ── */
.price-calc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--success-light);
  color: var(--success-text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88rem;
  margin-top: 4px;
}
.price-calc strong { font-size: 1rem; font-weight: 700; }

/* ── Scanner ── */
#scanner-container {
  position: relative; width: 100%;
  aspect-ratio: 4/3; background: #000;
  border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 10px;
}
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.scanner-box {
  width: 55%; height: 38%;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  position: relative;
}
.scanner-box::before, .scanner-box::after,
.scanner-corner-bl, .scanner-corner-br {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border-color: white;
  border-style: solid;
}
.scanner-box::before { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scanner-box::after { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.scanner-corner-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.scanner-corner-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

#scan-result {
  background: var(--success-light);
  color: var(--success-text);
  border-radius: 8px; padding: 10px 12px;
  font-size: .88rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 64px 20px 40px;
  color: var(--text-muted);
}
.empty-icon {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--primary-faint), #ede9fe);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 18px;
}
.empty-state h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: .9rem; line-height: 1.5; }

/* ── Settings ── */
.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.settings-card-title {
  font-size: .75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 14px;
}
.connection-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--bg); margin-bottom: 10px;
  font-size: .85rem;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
  transition: background .2s;
}
.status-dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.status-dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-faint); }
#s-status-text { flex: 1; color: var(--text-muted); }
.settings-hint {
  font-size: .78rem; color: var(--text-muted); line-height: 1.45;
  margin-top: 8px; margin-bottom: 0;
}

/* ── Offline banner ── */
.offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: #fef2f2;
  border-bottom: 1.5px solid #fca5a5;
  font-size: .82rem;
  font-weight: 600;
  color: #b91c1c;
  text-align: center;
}
.offline-banner.show { display: flex; }

/* ── Shopping banner ── */
#shopping-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--primary-faint);
  border-bottom: 1.5px solid #ddd6fe;
  font-size: .88rem;
  font-weight: 600;
  color: var(--primary-dark);
}
#shopping-banner-store::before {
  content: '🛒 ';
}
.shopping-banner-hint {
  font-size: .75rem;
  font-weight: 400;
  color: var(--primary);
  opacity: .7;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* ── Leave-store item rows ── */
.lsi-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.lsi-name {
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: 4px;
}
.lsi-qty {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.lsi-price-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}
.lsi-mode-toggle {
  flex-shrink: 0;
}
.lsi-price-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
}
.lsi-price-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

/* ── Unit conversion row ── */
.conv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.conv-eq {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .95rem;
  flex-shrink: 0;
}
.conv-unit-pill {
  background: var(--primary-faint);
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .88rem;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 24px;
}
.conv-row input[type=number] {
  width: 80px;
  flex-shrink: 0;
}
.conv-derived {
  margin-top: 12px;
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .82rem;
}
.conv-derived-title {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.conv-derived-item {
  color: var(--text);
  padding: 2px 0;
}

/* ── Qty row ── */
.qty-row { display: flex; gap: 10px; align-items: flex-end; }
.qty-row .qty-input-wrap { flex-shrink: 0; width: 90px; }
.qty-row .unit-wrap { flex: 1; }

.unit-display {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: .975rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ── Divider ── */
.divider {
  height: 1px; background: var(--border);
  margin: 14px 0;
}

/* ── Responsive ── */
@media (max-width: 400px) {
  header h1 { font-size: 1.1rem; }
  main { padding: 12px; padding-bottom: 96px; }
  #fab { padding: 0 18px 0 14px; height: 52px; font-size: .9rem; }
}

/* ── Expandable item body ── */
.item-body { cursor: pointer; }
.list-item.expanded .item-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

/* ── Edit button ── */
.item-edit {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 6px; border-radius: 8px;
  opacity: 0; transition: opacity .15s, color .15s, background .15s;
  line-height: 1; flex-shrink: 0;
}
.list-item:hover .item-edit { opacity: 1; }
.item-edit:hover { color: var(--primary); background: var(--primary-faint); }
@media (hover: none) {
  .item-edit { opacity: 0.4; }
}

/* ── Item thumbnail / photo button ── */
.item-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  display: block;
}
.item-thumb-btn {
  width: 44px; height: 44px;
  border-radius: 8px;
  border: 1.5px dashed var(--border-strong);
  background: var(--bg);
  color: var(--text-faint);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
  opacity: 0;
  transition: opacity .15s, border-color .15s, color .15s, background .15s;
}
.list-item:hover .item-thumb-btn { opacity: 1; }
.item-thumb-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-faint); }
@media (hover: none) {
  .item-thumb-btn { opacity: 0.35; }
}

/* ── List item enter / leave transitions ── */
.list-item {
  transition: opacity .18s ease, transform .18s ease, box-shadow .2s, border-color .2s;
}
.list-item.entering {
  opacity: 0;
  transform: translateY(-6px);
}
.list-item.leaving {
  opacity: 0 !important;
  transform: translateX(16px) !important;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease !important;
}
.section-label {
  transition: opacity .18s ease;
}
.section-label.entering { opacity: 0; }
.section-label.leaving  { opacity: 0; pointer-events: none; }

/* ── Theme toggle icon ── */
#btn-theme .theme-icon-sun,
#btn-theme .theme-icon-moon { transition: opacity .2s, transform .3s; }
:root[data-theme="dark"]  #btn-theme .theme-icon-sun  { display: none; }
:root[data-theme="light"] #btn-theme .theme-icon-moon { display: none; }

/* ── Dark-mode overrides for hardcoded component colors ── */
:root[data-theme="dark"] header {
  background: linear-gradient(135deg, #3b1d6e 0%, #5b21b6 60%, #4c1d95 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
}
:root[data-theme="dark"] .badge-local { background: #2a2a33; color: #9ca3af; }
:root[data-theme="dark"] .badge-store { background: #12303f; color: #7dd3fc; }
:root[data-theme="dark"] .offline-banner {
  background: #2a1414; border-bottom-color: #7f1d1d; color: #fca5a5;
}
:root[data-theme="dark"] #shopping-banner { border-bottom-color: #3b2f6b; }
:root[data-theme="dark"] .empty-icon { background: linear-gradient(135deg, #2a2150, #1f1840); }
:root[data-theme="dark"] .checkoff-section h3 .section-icon { background: var(--surface-2) !important; }
:root[data-theme="dark"] #product-suggestions { box-shadow: 0 8px 16px rgba(0,0,0,.5); }

/* ── Quantity stepper ── */
.stepper {
  display: flex; align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.stepper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.stepper input {
  border: none !important; border-radius: 0 !important;
  text-align: center; box-shadow: none !important;
  width: 100%; padding: 11px 4px; -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-btn {
  flex-shrink: 0; width: 40px; border: none;
  background: var(--bg); color: var(--primary);
  font-size: 1.3rem; font-weight: 600; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .08s; font-family: inherit;
  -webkit-user-select: none; user-select: none;
}
.stepper-btn:hover { background: var(--primary-faint); }
.stepper-btn:active { transform: scale(.9); background: var(--primary-faint); }
.qty-row .qty-input-wrap { width: 132px; }

/* ── Quick-add shortcuts ── */
#quick-add { display: none; }
#quick-add.show { display: block; margin-top: 4px; }
.qa-group { margin-top: 14px; }
.qa-group:first-child { margin-top: 4px; }
.qa-title {
  font-size: .72rem; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.qa-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qa-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-size: .88rem; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, background .15s, transform .08s, box-shadow .15s;
  max-width: 100%;
}
.qa-chip .qa-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.qa-chip:hover { border-color: var(--primary); background: var(--primary-faint); }
.qa-chip:active { transform: scale(.95); }
.qa-chip svg { color: var(--primary); flex-shrink: 0; }
.qa-chip .qa-count {
  font-size: .7rem; color: var(--text-faint);
  background: var(--bg); border-radius: 99px; padding: 1px 7px; font-weight: 600;
}

/* ── Price history ── */
.price-history {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 14px;
}
.price-history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
#checkoff-price-history-label {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.price-history-more {
  background: none; border: none; color: var(--primary);
  font-size: .78rem; font-weight: 600; cursor: pointer; font-family: inherit;
  padding: 2px 4px;
}
.price-history-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ph-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 6px 11px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-family: inherit; transition: border-color .15s, transform .08s;
}
.ph-chip:hover { border-color: var(--primary); }
.ph-chip:active { transform: scale(.94); }
.ph-chip .ph-price { font-weight: 700; font-size: .9rem; color: var(--text); }
.ph-chip .ph-date  { font-size: .72rem; color: var(--text-faint); }
.ph-stats {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.ph-stat {
  flex: 1; text-align: center; background: var(--bg);
  border-radius: var(--radius-sm); padding: 10px 6px;
}
.ph-stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 700; }
.ph-stat-value { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-top: 3px; }
.ph-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.ph-row:last-child { border-bottom: none; }
.ph-row .ph-row-price { font-weight: 700; }
.ph-row .ph-row-date { color: var(--text-muted); font-size: .82rem; }
.ph-empty { text-align: center; color: var(--text-muted); font-size: .9rem; padding: 24px 0; }
#price-history-modal { z-index: 60; }

/* ── Price comparison vs last purchase ── */
.price-compare {
  margin-top: 8px; padding: 8px 12px;
  border-radius: 8px; font-size: .82rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.price-compare.up   { background: var(--danger-faint);  color: var(--danger); }
.price-compare.down { background: var(--success-light); color: var(--success-text); }
.price-compare.same { background: var(--bg); color: var(--text-muted); }

/* ── Skeleton loading ── */
.skeleton-item {
  border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.sk-bar {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border) 37%, var(--bg-subtle) 63%);
  background-size: 400% 100%;
  border-radius: 6px; animation: sk-shimmer 1.4s ease infinite;
}
.sk-circle { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.sk-line-1 { height: 11px; width: 60%; }
.sk-line-2 { height: 9px;  width: 35%; }
@keyframes sk-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Undo toast action ── */
#toast.has-action { padding-right: 6px; }
.toast-undo {
  background: rgba(255,255,255,.16); border: none; color: var(--toast-text);
  font-weight: 700; font-size: .82rem; cursor: pointer;
  padding: 6px 12px; border-radius: 7px; margin-left: 12px; font-family: inherit;
  letter-spacing: .02em;
}
.toast-undo:active { transform: scale(.94); }
#toast .toast-undo { vertical-align: middle; }

/* ── Motion polish ── */
.btn:active:not(:disabled) { transform: scale(.97); }
.variant-chip:active { transform: scale(.98); }
.view-btn:active, .sync-toggle button:active { transform: scale(.96); }

/* ── Add person modal ── */
.ap-header { padding-bottom: 4px; }
.ap-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  margin-bottom: 8px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-faint);
  padding: 4px 11px 4px 8px; border-radius: 999px;
}
.ap-eyebrow-icon {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 999px;
  background: var(--primary); color: #fff;
}
.ap-eyebrow-icon svg { stroke: #fff; }
.ap-sub {
  margin-top: 7px;
  font-size: .88rem; line-height: 1.5;
  color: var(--text-muted);
  max-width: 42ch;
}

.ap-user-wrap, .ap-pw-wrap { position: relative; }
.ap-pw-wrap input { padding-right: 46px; }
.ap-peek {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-faint); border-radius: 8px;
  transition: background .15s, color .15s;
}
.ap-peek:hover { background: var(--bg-subtle); color: var(--text-muted); }
.ap-peek .peek-hide { display: none; }
.ap-peek.on .peek-show { display: none; }
.ap-peek.on .peek-hide { display: block; }

.ap-field-msg {
  min-height: 1.05rem;
  margin-top: 5px;
  font-size: .76rem; font-weight: 500;
  color: var(--text-faint);
  transition: color .15s;
}
.ap-field-msg.ok { color: var(--success); }
.ap-field-msg.bad { color: var(--danger); }
input.ap-invalid { border-color: var(--danger); }
input.ap-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.12); }

.ap-strength {
  height: 5px; border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  margin-top: 8px;
}
.ap-strength-fill {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  transition: width .35s cubic-bezier(.16,1,.3,1), background .35s;
}
.ap-strength-fill.s1 { width: 25%;  background: var(--danger); }
.ap-strength-fill.s2 { width: 50%;  background: var(--warning); }
.ap-strength-fill.s3 { width: 75%;  background: #2563eb; }
.ap-strength-fill.s4 { width: 100%; background: var(--success); }

.ap-error {
  margin-top: 4px;
  min-height: 1rem;
  font-size: .85rem; font-weight: 600;
  color: var(--danger);
}
.ap-error:empty { margin: 0; min-height: 0; }

#ap-create .ap-spinner { display: none; }
#ap-create.loading .ap-btn-label { opacity: 0; }
#ap-create.loading .ap-spinner {
  display: block; width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%;
  animation: ap-spin .7s linear infinite;
}
#ap-create { justify-content: center; min-width: 150px; }
#ap-create.loading { pointer-events: none; }
@keyframes ap-spin { to { transform: rotate(360deg); } }

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


/* ── New product at the shelf ── */
.seg-toggle { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: .9rem; cursor: pointer;
}
.seg-btn.active { border-color: var(--primary); background: var(--primary); color: var(--on-primary, #fff); }

.na-cam { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.na-cam video { width: 100%; display: block; max-height: 46vh; object-fit: cover; }
.na-shots { display: flex; gap: 8px; margin-top: 10px; }
.na-shots img { width: 62px; height: 62px; object-fit: cover; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }
.na-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.na-row:last-child { border-bottom: 0; }
.na-row .na-label { color: var(--text-dim, #888); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.na-row .na-value { font-weight: 600; text-align: right; }
.na-row .na-value.geschaetzt::after { content: " estimated"; font-weight: 500; font-size: .72rem; color: var(--text-dim, #888); }
.na-nutri { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 14px; margin-top: 6px; }
.na-nutri div { display: flex; justify-content: space-between; font-size: .86rem; }
.na-busy { text-align: center; padding: 26px 0; }
.na-busy .na-sec { font-size: 2rem; font-weight: 700; }
.btn-link {
  background: none; border: 0; padding: 4px 6px; margin-left: 8px;
  color: var(--primary); font-weight: 600; font-size: .82rem; cursor: pointer;
}
.modal-sub { font-size: .8rem; color: var(--text-dim, #888); margin-top: 2px; }

/* Three buttons (Abbrechen · Überspringen · Auslösen) do not fit a phone row at
   full width — on a real device the last one ran off the screen edge. */
#na-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
#na-buttons .btn { flex: 1 1 0; min-width: 0; padding-left: 10px; padding-right: 10px; font-size: .92rem; }

/* ── At home: putting away ── */
.er-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
  align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.er-row:last-child { border-bottom: 0; }
.er-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.er-row select { max-width: 38vw; }
.btn.er-ok { padding: 8px 14px; }

/* ── At home: tidying up ── */
.ar-gruppe {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 10px; background: var(--surface);
}
.ar-gruppe .check-row { padding: 4px 0; align-items: flex-start; }
/* Without this the long "PARENT (neu) · 5 Produkte" line pushes the checkbox
   onto a line of its own — it looked centred above the group on a phone. */
.ar-gruppe .check-row > span { flex: 1 1 auto; min-width: 0; }
.ar-gruppe .check-row input[type="checkbox"] { margin-top: 2px; }
.ar-kinder {
  font-size: .84rem; color: var(--text-dim, #888);
  padding: 6px 0 2px 30px; line-height: 1.5;
}

#einraeum-banner {
  display: flex; justify-content: center; gap: 10px; align-items: center;
  padding: 9px 14px; background: var(--surface-2); color: var(--text);
  font-size: .88rem; font-weight: 600; cursor: pointer;
  border-bottom: 1px solid var(--border);
}

/* Suggestion list under the parent field. The native <datalist> dropdown in the
   Android WebView showed every entry unfiltered over half the screen. */
.na-vorschlaege { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.na-vorschlaege button {
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface-2);
  color: var(--text); font-size: .84rem; font-weight: 600;
}
