:root {
  --bg:          #1e2d40;
  --card:        #2a3f57;
  --card2:       #324a63;
  --border:      #3d5a75;
  --accent:      #38bdf8;
  --green:       #4ade80;
  --yellow:      #fbbf24;
  --red:         #f87171;
  --orange:      #f97316;
  --text:        #f1f5f9;
  --muted:       #94a3b8;
  --chart-tick:  #888;
  --chart-grid:  #333;
  --heart-off:   #555;
  --star-off:    #666;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:          #f0f4f8;
    --card:        #ffffff;
    --card2:       #e2eaf3;
    --border:      #b8cfe0;
    --accent:      #0284c7;
    --green:       #16a34a;
    --yellow:      #f59e0b;
    --red:         #dc2626;
    --orange:      #ea580c;
    --text:        #1e2d40;
    --muted:       #4a6480;
    --chart-tick:  #666;
    --chart-grid:  #ddd;
    --heart-off:   #ccc;
    --star-off:    #ccc;
  }
}

[data-theme="light"] {
  --bg:          #f0f4f8;
  --card:        #ffffff;
  --card2:       #e2eaf3;
  --border:      #b8cfe0;
  --accent:      #0284c7;
  --green:       #16a34a;
  --yellow:      #f59e0b;
  --red:         #dc2626;
  --orange:      #ea580c;
  --text:        #1e2d40;
  --muted:       #4a6480;
  --chart-tick:  #666;
  --chart-grid:  #ddd;
  --heart-off:   #ccc;
  --star-off:    #ccc;
}

html, body { overflow-x: hidden; }
body { background: var(--bg); color: var(--text); }
#app { height: 100dvh; overflow: hidden; }

/* ── Search bar ── */
#search-bar {
  display: flex; gap: 8px; padding: 10px 12px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: relative;
}
#search-input {
  flex: 1; padding: 8px 12px;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; outline: none;
}
#search-input::placeholder { color: var(--muted); }
#search-btn {
  padding: 8px 14px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600; background: var(--accent); color: #fff;
  white-space: nowrap;
}
#scan-btn {
  padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--card2); color: var(--text);
  overflow: hidden; display: flex; align-items: center;
}
#scan-btn img { display: block; height: 28px; width: auto; }
#options-btn {
  padding: 0; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--card2); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  width: 44px; min-width: 44px; max-width: 44px; flex-shrink: 0;
}
#options-btn svg { width: 24px; height: 24px; display: block; }
#options-btn.active {
  border-color: var(--accent); color: var(--accent);
}
#options-panel {
  flex: 1; display: flex; flex-direction: column; overflow-y: auto;
}
#options-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600;
}
#options-close {
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 14px; color: var(--text);
}
#options-panel-body {
  padding: 16px;
}

/* ── Search results dropdown ── */
#search-dropdown {
  display: none;
  position: absolute; top: 100%; left: 12px; right: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; z-index: 100; max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
}
#search-dropdown .sr-item,
#search-dropdown .recent-search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer;
  border-top: 1px solid var(--border); font-size: 14px;
}
#search-dropdown .sr-item:first-child,
#search-dropdown .recent-search-item:first-child { border-top: none; }
#search-dropdown .sr-item:hover,
#search-dropdown .recent-search-item:hover { background: var(--card2); }
#search-dropdown .sr-thumb { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; border-radius: 3px; }
#search-dropdown .sr-text { min-width: 0; }
#search-dropdown .sr-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#search-dropdown .sr-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
#search-dropdown .recent-search-icon {
  color: var(--muted); font-size: 14px; line-height: 1; width: 18px; text-align: center; flex-shrink: 0;
}
#search-dropdown .recent-search-text {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650;
}

/* ── Scanner ── */
#scanner-container { display: none; }
#scanner-wrap {
  position: relative;
  width: 100%;
  background: #000;
  max-height: 38vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#video { display: block; width: 100%; height: auto; max-height: 38vh; object-fit: cover; }
#scan-line {
  position: absolute;
  left: 10%; right: 10%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: scan 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scan {
  0%   { top: 20%; }
  50%  { top: 80%; }
  100% { top: 20%; }
}
#stop-btn {
  display: block; width: 100%; padding: 10px;
  background: color-mix(in srgb, var(--red) 15%, var(--card));
  color: var(--red); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  letter-spacing: .3px;
}
#stop-btn:hover { background: color-mix(in srgb, var(--red) 25%, var(--card)); }

/* ── Location dot (inside mode-geo button) ── */
.loc-dot {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; background: var(--muted);
  margin-right: 5px; vertical-align: -1px; flex-shrink: 0;
}
.loc-dot.ok   { background: var(--green); }
.loc-dot.warn { background: var(--yellow); }
.loc-dot.err  { background: var(--red); }

/* ── Product section (top-level accordion) ── */
.product-section {
  background: var(--card); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
}
.product-section-bar {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; cursor: pointer; user-select: none;
  background: var(--card);
}
.ps-right {
  display: flex; flex-direction: column; align-items: center;
  align-self: stretch; flex-shrink: 0;
}
.ps-thumb {
  width: 80px; height: 80px; flex-shrink: 0;
  object-fit: contain; border-radius: 4px; background: #fff;
}
.ps-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ps-name-row { display: flex; align-items: flex-start; gap: 6px; }
.ps-name {
  flex: 1; min-width: 0;
  font-size: 16px; font-weight: 700;
  overflow-wrap: break-word; word-break: break-word;
}
.ps-top-btns { display: flex; align-items: center; gap: 2px; }
.ps-edit {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); width: 22px; height: 22px; flex-shrink: 0;
  text-decoration: none; opacity: .55; transition: opacity .15s;
}
.ps-edit:hover { opacity: 1; }
.ps-edit svg { width: 14px; height: 14px; display: block; }
.ps-camera {
  background: none; border: none; cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0; width: 22px; height: 22px; display: flex; align-items: center;
  justify-content: center; opacity: .55; transition: opacity .15s; flex-shrink: 0;
}
.ps-camera:hover { opacity: 1; }
.ps-remove {
  background: none; border: none; color: var(--muted); font-size: 18px;
  line-height: 1; cursor: pointer; padding: 0 2px; flex-shrink: 0; margin-top: -1px;
}
.ps-heart {
  background: none; border: none; font-size: 26px; line-height: 1;
  cursor: pointer; padding: 4px; flex-shrink: 0;
  color: var(--heart-off); transition: color .15s; margin: auto 0;
}
.ps-heart:hover { color: var(--muted); }
.ps-heart.fav { color: #ff453a; }
.ps-heart.fav:hover { color: #ff453a; opacity: .75; }
.ps-meta { font-size: 11px; color: var(--muted); }
.ps-price-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.ps-price { font-size: 16px; color: var(--green); font-weight: 700; white-space: nowrap; }
.ps-toggle { color: var(--muted); font-size: 24px; }
.stale-badge {
  display: inline-flex; align-items: center; justify-content: center;
  max-width: 100%; padding: 2px 6px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--yellow) 50%, var(--border));
  color: var(--yellow);
  background: color-mix(in srgb, var(--yellow) 12%, var(--card));
  font-size: 10px; font-weight: 700; line-height: 1.2;
  white-space: nowrap;
}
.stale-badge-old {
  border-color: color-mix(in srgb, var(--orange) 60%, var(--border));
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 12%, var(--card));
}
.stale-badge-block { margin-top: 4px; }
.stale-badge-inline { margin-left: 6px; vertical-align: 1px; }
.stale-badge-tight { margin-top: 3px; font-size: 9px; padding: 1px 5px; }
.product-section-body { display: none; border-top: 1px solid var(--border); }
.product-section.open .product-section-body { display: block; }
.product-section.open .ps-toggle { display: inline-block; transform: rotate(180deg); }

/* ── Company block ── */
.company-block { border-top: 1px solid var(--border); }
.company-block:first-child { border-top: none; }
.company-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: var(--card2); cursor: pointer;
  user-select: none;
}
.company-name { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.company-header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.company-logo { width: 20px; height: 20px; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.company-price { font-size: 16px; font-weight: 700; color: var(--green); }
.company-toggle { color: var(--muted); font-size: 24px; }

.store-list { display: none; }
.company-block.open .store-list { display: block; }
.company-block.open .company-toggle { transform: rotate(180deg); display: inline-block; }

/* ── Store row ── */
.store-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border);
  cursor: pointer;
}
.store-row:first-child { border-top: none; }
.store-row:hover { background: var(--card2); }
.store-chart-panel {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--card2);
}
.store-info { flex: 1; min-width: 0; }
.store-address { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-city { font-size: 11px; color: var(--muted); }
.store-left-actions { display: flex; align-items: center; flex-shrink: 0; }
.store-right { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; text-align: right; }
.store-price-wrap { display: flex; align-items: center; gap: 4px; }
.store-price { font-size: 16px; font-weight: 700; }
.store-price.cheap { color: var(--green); }
.store-price.expensive { color: var(--red); }
.store-unit-price { font-size: 11px; color: var(--muted); white-space: nowrap; margin-top: 1px; }
.special-badge {
  font-size: 10px; font-weight: 700; color: #fff;
  background: var(--orange); border-radius: 3px;
  padding: 1px 3px; line-height: 1; flex-shrink: 0;
}
.store-dist { font-size: 11px; color: var(--muted); margin-top: 2px; }
.store-map-btn { flex-shrink: 0; text-decoration: none; padding: 4px; display: flex; }
.store-star-btn {
  font-size: 20px; flex-shrink: 0; padding: 4px;
  background: none; border: none; cursor: pointer; line-height: 1;
  color: var(--star-off); transition: color .15s;
}
.store-star-btn:hover { color: var(--muted); }
.store-star-btn.fav { color: var(--yellow); }
.store-star-btn.fav:hover { color: var(--yellow); opacity: .75; }

/* ── Toast ── */
#toast {
  position: fixed;
  background: rgba(30,30,30,.92); color: #fff;
  padding: 8px 14px; border-radius: 16px;
  font-size: 13px; white-space: nowrap; pointer-events: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
  opacity: 0; transition: opacity .2s; z-index: 9999;
}
#toast.show { opacity: 1; }

/* ── States ── */
.loading-card {
  background: var(--card); border-radius: 12px; padding: 24px;
  text-align: center; color: var(--muted); font-size: 13px;
  border: 1px solid var(--border); animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.empty-card {
  background: var(--card); border-radius: 12px; padding: 24px;
  text-align: center; color: var(--muted); font-size: 13px;
  border: 1px solid var(--border);
}
.empty-card .empty-action-btn {
  margin-top: 12px;
  border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff;
  padding: 8px 12px; font-size: 13px; font-weight: 750;
  cursor: pointer;
}
.empty-card .empty-action-btn:hover { filter: brightness(1.05); }
.lists-login-empty {
  text-align: left;
}
.lists-login-title {
  color: var(--text);
  font-weight: 750;
  text-align: center;
}
.lists-login-benefits {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.45;
}
.lists-login-benefits li + li {
  margin-top: 6px;
}
.lists-login-empty .empty-action-btn {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
/* ── Chart ── */
.chart-wrap { padding: 4px 14px 12px; }
.chart-btn {
  display: block; width: 100%; padding: 8px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 13px; cursor: pointer; text-align: center;
}
.chart-btn:hover { border-color: var(--accent); color: var(--accent); }
.chart-btn.loading { opacity: .5; pointer-events: none; }
.chart-panel { display: none; padding-top: 12px; }
.chart-periods { display: flex; gap: 6px; margin-bottom: 10px; }
.chart-period-btn {
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px;
  background: none; color: var(--muted);
}
.chart-period-btn:hover { border-color: var(--accent); color: var(--accent); }
.chart-period-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Mode bar ── */
#mode-bar {
  display: flex; gap: 6px; padding: 8px 12px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.mode-btn {
  flex: 1; padding: 7px 4px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card2);
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 200; display: flex; align-items: flex-end;
}
.modal-panel {
  background: var(--card); width: 100%; max-height: 80vh;
  border-radius: 16px 16px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
/* Lists picker modal */
#modal-lists-picker {
  justify-content: center; align-items: center;
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(12px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px));
}
#modal-lists-picker .modal-panel {
  max-width: 480px; max-height: min(560px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
  border-radius: 16px;
}
#modal-list-share { justify-content: center; align-items: center; padding: 12px; }
#modal-list-share .modal-panel { max-width: 560px; max-height: min(760px, calc(100dvh - 24px)); border-radius: 16px; }
#modal-discount-scope { justify-content: center; align-items: center; padding: 12px; }
#modal-discount-scope .modal-panel { max-width: 560px; max-height: min(680px, calc(100dvh - 24px)); border-radius: 16px; }
#modal-discount-category { justify-content: center; align-items: center; padding: 12px; }
#modal-discount-category .modal-panel { max-width: 560px; max-height: min(680px, calc(100dvh - 24px)); border-radius: 16px; }
#modal-basket-scope { justify-content: center; align-items: center; padding: 12px; }
#modal-basket-scope .modal-panel { max-width: 520px; max-height: min(680px, calc(100dvh - 24px)); border-radius: 16px; }
#modal-location-intro { justify-content: center; align-items: center; padding: 12px; }
#modal-location-intro .modal-panel { max-width: 460px; max-height: min(520px, calc(100dvh - 24px)); border-radius: 16px; }
.location-intro-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.location-intro-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}
.location-intro-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.location-intro-note {
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  padding: 10px;
}
.location-intro-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}
.location-intro-primary,
.location-intro-secondary {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.location-intro-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}
.location-intro-secondary {
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
}
.location-intro-primary:hover,
.location-intro-secondary:hover { filter: brightness(1.05); }
.modal-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; cursor: pointer; border-top: 1px solid var(--border);
  font-size: 15px;
}
.modal-list-item:first-child { border-top: none; }
.modal-list-item:hover { background: var(--card2); }
.modal-list-item-main {
  min-width: 0; display: flex; flex-direction: column; gap: 3px;
}
.modal-list-item-name {
  color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis;
}
.modal-list-item-meta,
.modal-list-item-count { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.share-modal-content {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px;
}
.share-modal-copy {
  color: var(--muted); font-size: 13px; line-height: 1.35;
}
.share-modal-form {
  display: grid; grid-template-columns: minmax(0, 1fr) 118px auto; gap: 8px;
}
.share-modal-form input,
.share-modal-form select {
  min-width: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 9px 10px; font-size: 14px; outline: none;
}
.share-modal-form button,
.share-row button {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 9px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.share-modal-form button {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.share-list {
  display: flex; flex-direction: column; gap: 6px;
}
.share-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 118px auto; gap: 8px; align-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); padding: 8px;
}
.share-row-main { min-width: 0; }
.share-row-name { font-size: 14px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-row-status { color: var(--muted); font-size: 12px; margin-top: 2px; }
.share-row select {
  min-width: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 8px; font-size: 13px; outline: none;
}
.share-row-remove:hover { border-color: var(--red); color: var(--red); }
@media (max-width: 520px) {
  .share-modal-form,
  .share-row { grid-template-columns: 1fr; }
  .share-modal-form button,
  .share-row button,
  .share-row select { width: 100%; }
}

/* City modal constrained width */
#modal-city { justify-content: center; align-items: center; padding: 12px; }
#modal-city .modal-panel { max-width: 680px; max-height: min(760px, calc(100dvh - 24px)); border-radius: 16px; }

/* Stores modal anchored at top so keyboard doesn't push it around */
#modal-stores {
  align-items: flex-start; justify-content: center;
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    env(safe-area-inset-right, 0px)
    calc(12px + env(safe-area-inset-bottom, 0px))
    env(safe-area-inset-left, 0px);
}
#modal-stores .modal-panel {
  margin: 0;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  border-radius: 16px; max-width: 680px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-back {
  background: none; border: none; color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 8px 0 0; margin-right: 2px;
}
.modal-search {
  padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-search input {
  width: 100%; background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; color: var(--text);
  font-size: 14px; outline: none; box-sizing: border-box;
}
.modal-city-chip {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 5px 10px;
  background: var(--accent); color: #fff;
  border-radius: 20px; width: fit-content; font-size: 13px; font-weight: 600;
}
.modal-city-chip button {
  background: none; border: none; color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px;
  opacity: .8;
}
.modal-city-chip button:hover { opacity: 1; }
.modal-body { overflow-y: auto; flex: 1; }
.modal-section-label {
  padding: 8px 14px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
}
.modal-city-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; cursor: pointer; border-top: 1px solid var(--border);
  font-size: 14px;
}
.modal-city-item:first-of-type { border-top: none; }
.modal-city-item:hover { background: var(--card2); }
.modal-city-all { font-weight: 600; color: var(--accent); }
.modal-city-item.selected { background: var(--card2); }
.modal-city-count { font-size: 11px; color: var(--muted); }
.modal-city-divider { border: none; border-top: 2px solid var(--border); margin: 4px 0; }
.modal-store-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid var(--border);
  cursor: pointer;
}
.modal-store-item:first-of-type { border-top: none; }
.modal-store-item:hover { background: var(--card2); }
.modal-store-logo { width: 22px; height: 22px; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.modal-store-info { flex: 1; min-width: 0; }
.modal-store-addr { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-store-city { font-size: 11px; color: var(--muted); }
.modal-store-check {
  width: 20px; height: 20px; flex-shrink: 0; cursor: pointer; accent-color: var(--accent);
}
.modal-scope-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer; border-top: 1px solid var(--border);
}
.modal-scope-item:first-of-type { border-top: none; }
.modal-scope-item:hover, .modal-scope-item.selected { background: var(--card2); }
.modal-scope-section {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 9px 14px; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .55px; color: var(--muted);
  background: color-mix(in srgb, var(--card2) 58%, var(--card));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.modal-scope-section-icon { width: 24px; text-align: center; flex-shrink: 0; }
.modal-scope-icon {
  width: 28px; height: 28px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; text-align: center;
}
.modal-scope-logo {
  width: 28px; height: 28px; object-fit: contain; border-radius: 5px;
  background: rgba(255,255,255,.92);
}
.modal-scope-logo-grid {
  width: 28px; height: 28px; display: grid; grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr); gap: 2px;
}
.modal-scope-logo-grid .modal-scope-logo {
  width: 13px; height: 13px; border-radius: 3px;
}
.modal-scope-main { flex: 1; min-width: 0; }
.modal-scope-title { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-scope-sub { margin-top: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-scope-check { color: var(--accent); font-weight: 800; flex-shrink: 0; }
.modal-scope-action {
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  flex-shrink: 0;
}
.modal-city-group-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px 4px; border-top: 1px solid var(--border);
  cursor: pointer;
}
.modal-city-group-header:first-of-type { border-top: none; }
.modal-city-group-name { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.modal-city-group-toggle { font-size: 10px; color: var(--muted); }
.modal-city-group-stores { display: none; }
.modal-city-group-header.open + .modal-city-group-stores { display: block; }

.error-card {
  background: color-mix(in srgb, var(--red) 12%, var(--card));
  border-radius: 12px; padding: 14px;
  color: var(--red); font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--red) 30%, var(--border));
  transition: opacity .4s ease;
}
.error-card.fading { opacity: 0; }

/* ── Options panel ── */
.options-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 0 18px;
  border-bottom: 1px solid var(--border);
}
.options-tab {
  position: relative;
  min-height: 36px;
  border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted);
  padding: 8px 6px 9px; font-size: 13px; font-weight: 750; cursor: pointer;
}
.options-tab:hover { color: var(--text); }
.options-tab:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: -2px;
}
.options-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.options-section { margin-bottom: 20px; }
.options-section--bordered {
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.options-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); margin-bottom: 8px;
}
.options-section-desc {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  margin-bottom: 12px;
}
.theme-buttons { display: flex; gap: 6px; }
.theme-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card2);
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.theme-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
[data-theme="light"] .theme-btn.active { color: #fff; }

/* ── Options panel - companies ── */
.options-company-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.options-company-all-btn, .options-company-none-btn {
  flex: 1; padding: 7px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card2);
  color: var(--text); font-size: 13px; font-weight: 600;
}
.options-company-all-btn:hover, .options-company-none-btn:hover {
  border-color: var(--accent); color: var(--accent);
}
.options-companies-list { display: flex; flex-direction: column; }
.options-company-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--border);
  cursor: pointer;
}
.options-company-row:first-child { border-top: none; }
.options-company-row:hover { background: var(--card2); }
.options-company-logo {
  width: 22px; height: 22px; object-fit: contain; border-radius: 3px; flex-shrink: 0;
}
.options-company-name { flex: 1; font-size: 13px; }
.options-company-star {
  font-size: 20px; flex-shrink: 0; padding: 4px;
  background: none; border: none; cursor: pointer; line-height: 1;
  color: var(--star-off); transition: color .15s;
}
.options-company-star:hover { color: var(--muted); }
.options-company-star.fav { color: var(--yellow); }
.options-company-star.fav:hover { color: var(--yellow); opacity: .75; }

/* ── Options panel - account ── */
.account-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--card2);
  padding: 12px;
}
.account-title { font-size: 15px; font-weight: 750; margin-bottom: 4px; overflow-wrap: anywhere; }
.account-switch {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.account-switch-btn {
  flex: 1; border: 1px solid var(--border); background: var(--card2); color: var(--muted);
  border-radius: 8px; padding: 8px 6px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.account-switch-btn.active { color: #fff; border-color: var(--accent); background: var(--accent); }
.account-form { display: flex; flex-direction: column; gap: 10px; }
.account-form label {
  display: flex; flex-direction: column; gap: 5px; color: var(--muted);
  font-size: 12px; font-weight: 700;
}
.account-form input {
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  border-radius: 8px; padding: 10px; font-size: 15px; outline: none;
}
.account-form input:focus { border-color: var(--accent); }
.account-btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 10px 12px; font-size: 14px; font-weight: 750; cursor: pointer;
}
.account-btn-secondary {
  background: var(--card); color: var(--text); border-color: var(--border);
}
.account-msg { min-height: 18px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.account-msg.err { color: var(--red); }

/* ── Ostali block ── */
.others-block { border-top: 1px solid var(--border); }
.others-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; cursor: pointer; user-select: none;
  background: color-mix(in srgb, var(--card2) 60%, var(--bg));
}
.others-name {
  font-weight: 600; font-size: 13px; text-transform: uppercase;
  letter-spacing: .5px; display: flex; align-items: center; gap: 7px;
}
.others-price { font-size: 16px; font-weight: 700; color: var(--green); }
.others-toggle { color: var(--muted); font-size: 24px; }
.others-body { display: none; }
.others-block.open .others-body { display: block; }

/* ── Camera modal ── */
#modal-camera { align-items: center; justify-content: center; padding: 0 12px; }
#cam-panel {
  max-width: 480px; border-radius: 16px;
  height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column;
}
#cam-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: none; }
#cam-video-wrap { border-radius: 8px; overflow: hidden; background: #000; flex: 1; min-height: 100px; }
#cam-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
#cam-crop-wrap { display: none; width: 100%; flex: 1; min-height: 50px; background: #000; border-radius: 8px; overflow: hidden; }
@media (orientation: landscape) and (max-height: 500px) {
  #cam-body { gap: 8px; padding: 10px 16px; }
}
#cam-crop-wrap.active { display: block; }
#cam-preview { display: block; width: 100%; height: 100%; }
#cam-crop-wrap .cropper-point {
  width: 12px; height: 12px;
}
#cam-crop-wrap .cropper-point::before {
  content: ''; position: absolute;
  top: -22px; left: -22px; right: -22px; bottom: -22px;
}
#cam-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
#cam-actions .cam-btn { flex: 1; text-align: center; }
#cam-upload-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#cam-upload-row.public-pending #cam-status { display: none; }
#cam-upload-note { width: 100%; color: var(--muted); font-size: 12px; line-height: 1.35; }
#cam-upload-row select {
  flex: 1; min-width: 120px; background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 14px; outline: none;
}
.cam-btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text); cursor: pointer; font-size: 14px;
}
.cam-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.cam-btn:disabled { opacity: .5; cursor: default; }

/* ── Tab panels ── */
.tab-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  min-width: 0;
}
#panel-search,
#panel-search-results { overflow-y: hidden; overflow-x: hidden; }

/* ── Tab bar ── */
#tab-bar {
  display: flex; flex-shrink: 0;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
.tab-btn {
  padding: 9px 12px;
  border: none; border-bottom: 2px solid transparent;
  background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-spacer { flex: 1; }
.tab-link { text-decoration: none; display: inline-flex; align-items: center; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
@media (max-width: 420px) {
  .tab-btn { padding-inline: 6px; font-size: 12px; }
}

/* ── SEO pages ── */
body.pg-page #app {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
.pg-page #search-bar { flex-shrink: 0; }
.pg-search-form { display: flex; gap: 8px; width: 100%; }
.pg-main {
  flex: 1;
  overflow: visible;
  padding: 14px 12px 28px;
}
.pg-crumbs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  color: var(--muted); font-size: 12px; margin-bottom: 12px;
}
.pg-crumbs a { color: var(--muted); text-decoration: none; }
.pg-crumbs a:hover { color: var(--accent); }
.pg-header { margin-bottom: 14px; }
.pg-header h1 {
  font-size: 26px; line-height: 1.15; letter-spacing: 0; margin-bottom: 4px;
}
.pg-header p { color: var(--muted); }
.pg-category-sections { display: flex; flex-direction: column; gap: 14px; }
.pg-category-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.pg-category-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 13px;
  background: var(--card2);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.pg-category-bar span:last-child { color: var(--muted); font-size: 12px; font-weight: 600; }
.pg-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}
.pg-child-grid {
  padding: 0;
  margin-bottom: 14px;
}
.pg-category-tile {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--card2) 70%, var(--card));
}
.pg-category-tile img {
  grid-row: 1 / span 2;
  width: 52px; height: 52px; object-fit: contain;
  border-radius: 6px; background: #fff;
}
.pg-category-tile span {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: break-word;
}
.pg-category-tile small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.pg-product-list { display: flex; flex-direction: column; gap: 8px; }
.pg-category-product-card {
  color: var(--text);
  text-decoration: none;
}
.pg-category-product-card .dc-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.pg-category-product-card .dc-name,
.pg-category-product-card .dc-meta,
.pg-category-product-card .fav-price {
  display: block;
}
.pg-pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 16px; color: var(--muted);
}
.pg-pagination a, .pg-pagination span {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
}
.pg-pagination span { color: var(--muted); }
.pg-product-page { display: flex; flex-direction: column; gap: 16px; }
.pg-product-hero {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.pg-product-hero > img {
  width: 150px; height: 150px; object-fit: contain;
  border-radius: 8px; background: #fff;
}
.pg-product-hero h1 {
  font-size: 23px; line-height: 1.15; letter-spacing: 0; margin-bottom: 8px;
  overflow-wrap: break-word;
}
.pg-product-hero p { color: var(--muted); margin-top: 4px; }
.pg-product-brand { color: var(--text) !important; font-weight: 700; }
.pg-barcode { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.pg-chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pg-chip-row a {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  text-decoration: none;
}
.pg-section {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.pg-section h2 { font-size: 17px; line-height: 1.2; margin-bottom: 10px; letter-spacing: 0; }
.pg-section-desc { color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.pg-feature-link {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
}
.pg-feature-link:hover { opacity: 0.85; }
.pg-spec-list { display: flex; flex-direction: column; gap: 8px; }
.pg-spec-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1fr);
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.pg-spec-list div:first-child { padding-top: 0; border-top: none; }
.pg-spec-list dt { color: var(--muted); }
.pg-spec-list dd { color: var(--text); font-weight: 700; overflow-wrap: break-word; }
.pg-price-list { display: flex; flex-direction: column; }
.pg-price-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.pg-price-row:first-child { border-top: none; padding-top: 0; }
.pg-price-row > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pg-price-row > div:last-child { text-align: right; flex-shrink: 0; }
.pg-price-row small { color: var(--muted); }

@media (max-width: 520px) {
  .pg-category-grid { grid-template-columns: 1fr; }
  .pg-product-hero { grid-template-columns: 112px minmax(0, 1fr); }
  .pg-product-hero > img { width: 112px; height: 112px; }
  .pg-product-hero h1 { font-size: 20px; }
  .pg-spec-list div { grid-template-columns: 1fr; gap: 2px; }
}

/* ── Discount cards ── */
#discount-category-bar {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px 6px;
}
#discount-category-scroll {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#discount-category-scroll::-webkit-scrollbar { display: none; }
.category-filter-chip {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 999px; padding: 6px 10px;
  font-size: 12px; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.category-filter-chip.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  color: var(--accent);
}
.category-filter-chip:disabled {
  opacity: .5; cursor: default;
}
.discount-scope-chip {
  display: inline-flex; align-items: center; gap: 5px;
  max-width: 190px;
  background: color-mix(in srgb, var(--accent) 10%, var(--card2));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  color: var(--text);
}
.discount-scope-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.discount-scope-chip .discount-scope-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.discount-scope-chip .discount-scope-caret {
  flex-shrink: 0; opacity: .8;
}
.discount-category-chip {
  display: inline-flex; align-items: center; gap: 5px;
  max-width: 190px;
}
.discount-category-chip .discount-category-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modal-cat-parent {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .45px; color: var(--muted);
  background: color-mix(in srgb, var(--card2) 58%, var(--card));
  border-top: 1px solid var(--border);
}
.modal-cat-parent:first-of-type { border-top: none; }
.modal-cat-parent:hover, .modal-cat-parent.selected { background: var(--card2); }
.modal-cat-parent.selected { color: var(--accent); }
.modal-cat-parent-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.modal-cat-parent-icon img {
  width: 22px; height: 22px; object-fit: contain; border-radius: 4px;
}
.modal-cat-parent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-cat-child { padding-left: 28px; }
.modal-cat-child-icon img {
  width: 22px; height: 22px; object-fit: contain; border-radius: 4px;
  background: rgba(255,255,255,.85);
}
.modal-cat-count {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 999px; padding: 1px 6px; flex-shrink: 0;
}
#discounts-list {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
#discounts-list > * { flex-shrink: 0; }
.discount-section-header {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); padding: 6px 2px 2px;
}
.discount-card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  position: relative;
  cursor: pointer; transition: background .1s;
}
.discount-card:hover { background: var(--card2); }
.dc-thumb {
  width: 64px; height: 64px; object-fit: contain; border-radius: 4px;
  background: #fff; flex-shrink: 0;
}
.product-image-placeholder {
  background: color-mix(in srgb, var(--card2) 68%, #fff);
  opacity: .7;
  filter: saturate(.45) contrast(.92) brightness(1.08);
}
.dc-info { flex: 1; min-width: 0; }
.dc-name {
  font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.dc-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dc-category-row {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px;
}
.dc-category-chip {
  font-size: 10px; font-weight: 650; color: color-mix(in srgb, var(--muted) 78%, var(--card2));
  background: color-mix(in srgb, var(--muted) 6%, var(--card2));
  border: 1px solid color-mix(in srgb, var(--muted) 12%, var(--border));
  border-radius: 999px; padding: 1px 6px;
}
.dc-store {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-logos {
  display: flex; align-items: center; gap: 5px; margin-top: 5px; flex-wrap: wrap;
}
.dc-logo { width: 14px; height: 14px; object-fit: contain; border-radius: 2px; flex-shrink: 0; }
.dc-logo-lg { width: 20px; height: 20px; border-radius: 3px; }
.dc-extra {
  font-size: 10px; font-weight: 700; color: var(--muted);
  background: var(--card2); border-radius: 4px; padding: 1px 4px;
}
.dc-prices { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; gap: 2px; }
.dc-price-now { font-size: 16px; font-weight: 700; color: var(--green); white-space: nowrap; }
.dc-price-was { font-size: 12px; color: var(--muted); text-decoration: line-through; white-space: nowrap; }
.dc-saving {
  font-size: 11px; font-weight: 700; color: var(--orange); white-space: nowrap;
  background: color-mix(in srgb, var(--orange) 12%, var(--card2));
  border-radius: 4px; padding: 1px 5px;
}

/* ── Favorites tab ── */
#favorites-list {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
#categories-panel-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#favorites-list > * { flex-shrink: 0; }
.fav-card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  cursor: pointer; transition: background .1s;
}
.fav-card:hover { background: var(--card2); }
.fav-on-discount { border-color: color-mix(in srgb, var(--orange) 40%, var(--border)); }
#favorites-list .dc-info {
  display: flex; flex-direction: column; align-items: flex-start;
}
#favorites-list .dc-name,
#favorites-list .dc-meta,
#favorites-list .fav-price {
  display: block;
}
.fav-price { font-size: 14px; font-weight: 700; color: var(--green); margin-top: 4px; }
.fav-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.fav-discount-badge {
  display: inline-flex; width: fit-content; margin-top: 4px;
  font-size: 11px; font-weight: 700; color: var(--orange); white-space: nowrap;
  background: color-mix(in srgb, var(--orange) 12%, var(--card2));
  border-radius: 4px; padding: 2px 6px;
}
.fav-remove {
  font-size: 22px; padding: 4px;
  background: none; border: none; cursor: pointer; line-height: 1;
  color: #ff453a; transition: opacity .15s;
}
.fav-remove:hover { opacity: .7; }
.list-add-btn {
  min-width: max-content; max-width: none; min-height: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border)); border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--card2)); color: var(--accent);
  padding: 1px 6px; font-size: 10px; font-weight: 650; line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.list-add-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card2)); }
.list-add-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.discount-list-add {
  position: absolute; right: 12px; bottom: 8px;
}

/* ── User lists tab ── */
#lists-panel-content {
  padding: 10px 12px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.user-list-toolbar {
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.user-list-toolbar-main,
.user-list-toolbar-actions {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.user-list-select {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 8px 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; outline: none;
}
.user-list-toolbar button,
.user-list-more-menu button {
  flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 8px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-list-toolbar button:hover,
.user-list-more-menu button:hover { border-color: var(--accent); color: var(--accent); }
.user-list-wide-action {
  flex: 1 1 0; min-width: 0;
}
.user-list-more-btn {
  width: 38px; min-width: 38px; font-size: 18px !important; line-height: 1;
  padding-inline: 0; overflow: visible;
}
.user-list-more-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  z-index: 5;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 170px; padding: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.user-list-more-menu button {
  width: 100%; text-align: left;
}
.user-list-more-menu .danger:hover {
  border-color: var(--red); color: var(--red);
}
.user-list-primary-btn {
  background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important;
}
.user-list-primary-btn:hover { opacity: .88; }
.user-list-add-text {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px;
}
.user-list-add-text input {
  min-width: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text);
  padding: 9px 10px; font-size: 14px; outline: none;
}
.user-list-add-text input:focus { border-color: var(--accent); }
.user-list-add-text button {
  border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff;
  padding: 9px 12px; font-size: 13px; font-weight: 800; cursor: pointer;
}
.user-list-add-text button:hover { opacity: .88; }
@media (max-width: 420px) {
  .user-list-toolbar-actions { gap: 4px; }
  .user-list-toolbar-actions button {
    padding-inline: 6px;
    font-size: 12px;
  }
  .user-list-toolbar-actions .user-list-more-btn {
    width: 32px; min-width: 32px; padding-inline: 0;
  }
}
@media (max-width: 380px) {
  .user-list-toolbar-actions button {
    padding-inline: 5px;
    font-size: 11px;
  }
  .user-list-toolbar-actions .user-list-more-btn {
    width: 30px; min-width: 30px;
  }
}
.user-list-meta-line {
  color: var(--muted); font-size: 12px; font-weight: 650;
}
.user-list-invites {
  display: flex; flex-direction: column; gap: 6px;
}
.user-list-invite {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); padding: 8px;
}
.user-list-invite strong,
.user-list-invite span {
  display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-list-invite span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.user-list-invite button {
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--card2); color: var(--text);
  padding: 6px 8px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.user-list-invite-accept { color: var(--accent) !important; }
.user-list-items { display: flex; flex-direction: column; gap: 8px; }
.user-list-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); padding: 8px 10px; cursor: pointer;
}
.user-list-item.done { opacity: .62; }
.user-list-check { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); }
.user-list-item-main {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.user-list-item-name {
  font-size: 14px; font-weight: 750;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
}
.user-list-item.done .user-list-item-name { text-decoration: line-through; }
.user-list-text {
  width: 100%; min-width: 0;
  resize: none;
  border: 0; border-bottom: 1px solid transparent;
  background: transparent; color: var(--text);
  padding: 0 0 1px; outline: none;
  font: inherit; font-size: 14px; font-weight: 750; line-height: 1.25;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.user-list-text:focus { border-bottom-color: var(--accent); }
.user-list-item.done .user-list-text { text-decoration: line-through; }
.user-list-item-meta {
  color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-list-item-actor {
  color: var(--muted); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-list-item-fields { display: flex; gap: 6px; }
.user-list-item-fields input {
  min-width: 0; flex: 1;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--card2); color: var(--text);
  padding: 6px 8px; font-size: 12px; outline: none;
}
.user-list-qty-stepper {
  flex: 0 0 86px;
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 26px;
  touch-action: manipulation;
}
.user-list-qty-stepper button {
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  font-size: 16px; font-weight: 800; cursor: pointer; line-height: 1;
  touch-action: manipulation; user-select: none;
}
.user-list-qty-dec { border-radius: 7px 0 0 7px; }
.user-list-qty-inc { border-radius: 0 7px 7px 0; }
.user-list-qty-stepper button:hover { border-color: var(--accent); color: var(--accent); }
.user-list-qty-stepper button:disabled,
.user-list-item-fields input:disabled,
.user-list-check:disabled {
  cursor: default; opacity: .55;
}
.user-list-item-fields .user-list-qty {
  width: 100%; min-width: 0; flex: none;
  border-left: 0; border-right: 0; border-radius: 0;
  text-align: center; padding-inline: 4px;
  font-size: 15px; font-weight: 750;
  touch-action: manipulation;
}
.user-list-item-delete {
  flex-shrink: 0; width: 30px; height: 30px;
  border: 0; background: none; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer;
}
.user-list-item-delete:hover { color: var(--red); }
.basket-compare-panel {
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.basket-compare-header {
  display: flex; align-items: center; gap: 10px;
}
.basket-compare-header button {
  flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text); width: 36px; height: 36px;
  font-size: 18px; font-weight: 800; cursor: pointer;
}
.basket-compare-title { font-size: 16px; font-weight: 800; line-height: 1.2; }
.basket-compare-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.basket-compare-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  padding: 10px 12px;
}
.basket-compare-summary span {
  display: block; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; font-weight: 800; margin-bottom: 2px;
}
.basket-compare-summary strong { display: block; font-size: 14px; line-height: 1.25; }
.basket-compare-summary button,
.basket-compare-action {
  flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card2); color: var(--text); padding: 8px 10px;
  font-size: 12px; font-weight: 750; cursor: pointer;
}
.basket-scope-button {
  max-width: 148px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.basket-compare-table-wrap {
  overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card);
}
.basket-compare-table {
  border-collapse: separate; border-spacing: 0; min-width: 480px; width: max-content;
  font-size: 12px;
}
.basket-compare-table th,
.basket-compare-table td {
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 8px 6px; text-align: right; min-width: 70px;
  background: var(--card);
}
.basket-compare-table th:first-child,
.basket-compare-table td:first-child {
  position: sticky; left: 0; z-index: 2; text-align: left; min-width: 132px;
  max-width: 145px; background: var(--card);
}
.basket-compare-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--card2);
  font-weight: 800;
}
.basket-compare-table thead th:first-child { z-index: 4; background: var(--card2); }
.basket-compare-table tfoot th,
.basket-compare-table tfoot td {
  background: color-mix(in srgb, var(--card2) 70%, var(--card));
  font-weight: 800;
}
.basket-product-cell span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.25; white-space: normal;
}
.basket-product-cell b { color: var(--muted); font-weight: 850; }
.basket-substitute-row th,
.basket-substitute-row td {
  background: var(--card);
  border-bottom-color: color-mix(in srgb, var(--green) 14%, var(--border));
}
.basket-substitute-row th:first-child,
.basket-substitute-row td:first-child {
  background: color-mix(in srgb, var(--green) 4%, var(--card));
}
.basket-substitute-cell {
  position: sticky;
  padding-left: 16px !important;
  padding-right: 34px !important;
  padding-bottom: 15px !important;
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
}
.basket-substitute-cell span {
  display: block;
  overflow: visible;
  white-space: normal;
  line-height: 1.22;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
}
.basket-substitute-cell em {
  position: absolute; right: 4px; bottom: 3px; padding: 1px 3px;
  border-radius: 999px; background: color-mix(in srgb, var(--green) 14%, var(--card2));
  color: var(--green); font-size: 7px; line-height: 1.2; font-style: normal;
  font-weight: 900; text-transform: uppercase;
}
.basket-substitute-cell small {
  color: var(--muted); font-size: 10px; font-weight: 800;
}
.basket-compare-table td.substitute-available {
  background: color-mix(in srgb, var(--green) 4%, var(--card));
}
.basket-compare-table td.substitute {
  color: color-mix(in srgb, var(--text) 82%, var(--green));
  font-weight: 750;
}
.basket-compare-table td.missing-no-substitute {
  background: color-mix(in srgb, var(--red) 5%, var(--card));
}
.basket-substitute-total-row th,
.basket-substitute-total-row td {
  background: color-mix(in srgb, var(--green) 9%, var(--card2));
}
.basket-store-head {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  white-space: normal; line-height: 1.12; text-align: center;
}
.basket-store-head img {
  width: 18px; height: 18px; object-fit: contain; border-radius: 4px;
  background: rgba(255,255,255,.92); flex-shrink: 0;
}
.basket-store-head span {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 58px;
}
.basket-compare-table td.best { color: var(--green); font-weight: 850; }
.basket-compare-table td.worst { color: var(--red); font-weight: 850; }
.basket-compare-table td.stale {
  opacity: .74;
}
.basket-cell-stale {
  display: block; margin-top: 2px; color: var(--orange);
  font-size: 9px; line-height: 1.05; font-weight: 800;
}
.basket-compare-table td.best-total {
  color: var(--green); font-weight: 900;
}
.basket-compare-table td.worst-total {
  color: var(--red); font-weight: 900;
}
.basket-missing { color: var(--muted); }
.others-block.open .others-toggle { transform: rotate(180deg); display: inline-block; }

/* ── Product page panel ── */
#panel-product {
  flex: 1; background: var(--bg); display: flex; flex-direction: column;
  overflow: hidden;
}
#pp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 8px; min-height: 54px;
}
#pp-back {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; color: var(--text); font-size: 14px;
  white-space: nowrap; flex-shrink: 0;
}
#pp-header-right {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}
#pp-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
#pp-content { padding-bottom: 40px; }

/* Product page images */
.pp-images {
  padding: 14px 16px; display: flex; gap: 10px; align-items: flex-start; position: relative;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.pp-img-main {
  width: 168px; min-width: 168px; height: 168px; object-fit: contain;
  border-radius: 8px; background: #fff; cursor: pointer; flex-shrink: 0;
}
.pp-image-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pp-img-thumbs { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.pp-img-thumb {
  width: 56px; height: 56px; object-fit: contain;
  border-radius: 6px; background: #fff; cursor: pointer;
  opacity: 0.45; border: 1px solid var(--border); transition: opacity .15s;
}
.pp-img-thumb:hover { opacity: 0.9; }
.pp-image-missing {
  flex: 1; min-height: 168px; border: 1px dashed var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--card2) 72%, #fff);
  color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px; text-align: center;
}
.pp-image-missing-title { font-size: 16px; font-weight: 700; color: var(--text); }
.pp-image-missing-note { font-size: 12px; line-height: 1.35; max-width: 260px; }
.pp-image-upload-side {
  flex: 1; min-width: 150px; min-height: 168px; border: 1px dashed var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--card2) 64%, #fff);
  color: var(--muted); display: flex; flex-direction: column; justify-content: center;
  gap: 8px; padding: 14px; align-items: flex-start;
}
.pp-upload-image-btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px;
  padding: 8px 12px; font-size: 14px; font-weight: 650; cursor: pointer;
}
.pp-upload-image-btn:hover { filter: brightness(1.05); }
.pp-image-upload-action {
  border: 1px dashed color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--card2) 76%, #fff);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  text-align: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 72%, transparent);
  transition: background .15s, border-color .15s, transform .15s;
}
.pp-image-upload-action:hover {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--card2));
  filter: none;
  transform: translateY(-1px);
}
.pp-image-upload-action:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}
.pp-image-upload-cta {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent); border-radius: 8px;
  color: var(--accent); background: var(--card);
  padding: 7px 11px; font-size: 13px; font-weight: 700;
}
.pp-upload-image-link {
  position: absolute; right: 12px; bottom: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--card2)); color: var(--accent);
  border-radius: 999px; padding: 1px 6px;
  font-size: 10px; font-weight: 650; cursor: pointer; text-align: left;
}
.pp-upload-image-link:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--card2)); }
.pp-pending-image-note {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, #f4b942 14%, var(--card)); color: var(--text);
  font-size: 13px; line-height: 1.35;
}

/* Product page info */
.pp-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.pp-info-section { position: relative; padding-bottom: 38px; }
.pp-name { font-size: 17px; font-weight: 700; line-height: 1.35; margin-bottom: 5px; }
.pp-meta-row { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.pp-category-chip {
  display: inline-block;
  background: color-mix(in srgb, var(--muted) 6%, var(--card2));
  border: 1px solid color-mix(in srgb, var(--muted) 12%, var(--border));
  border-radius: 999px; padding: 1px 6px; font-size: 10px; font-weight: 650;
  color: color-mix(in srgb, var(--muted) 78%, var(--card2)); margin-top: 6px; margin-right: 4px;
}
.pp-info-actions {
  position: absolute; right: 16px; bottom: 10px;
}

/* Product page price summary */
.pp-price-summary {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--green) 6%, var(--card));
}
.pp-price-main { font-size: 26px; font-weight: 800; color: var(--green); line-height: 1; }
.pp-price-range { font-size: 13px; color: var(--muted); margin-top: 4px; }
.pp-unit-price { font-size: 13px; color: var(--muted); margin-top: 4px; }
.pp-price-stats { text-align: right; font-size: 12px; color: var(--muted); }
.pp-price-stats-val { font-weight: 700; color: var(--text); font-size: 14px; }

/* Product page section title */
.pp-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); padding: 14px 16px 4px;
}

/* Related products horizontal scroll */
.pp-related-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding: 8px 18px 18px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x mandatory;
  scroll-padding-left: 18px;
}
.pp-related-scroll::-webkit-scrollbar { display: none; }
.pp-related-tile {
  flex-shrink: 0; width: 136px; background: var(--card);
  border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; overflow: hidden; transition: background .1s; scroll-snap-align: start;
}
.pp-related-tile:hover { background: var(--card2); }
.pp-related-tile > img { width: 100%; height: 92px; object-fit: contain; background: #fff; display: block; }
.pp-related-tile-info { padding: 7px 9px 9px; }
.pp-related-tile-name {
  font-size: 12px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.pp-related-tile-qty { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-related-tile-price { font-size: 12px; font-weight: 700; color: var(--green); margin-top: 2px; }
@media (hover: hover) and (pointer: fine) {
  .pp-related-scroll {
    scrollbar-width: thin;
  }
  .pp-related-scroll::-webkit-scrollbar {
    display: block;
    height: 8px;
  }
  .pp-related-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
  }
  .pp-related-scroll::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* Gallery modal */
#modal-gallery {
  position: fixed; inset: 0; z-index: 400;
  background: #000; display: flex; flex-direction: column; touch-action: none;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
}
#gallery-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 10;
  background: rgba(255,255,255,.18); border: none; color: #fff;
  font-size: 22px; width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
#gallery-prev, #gallery-next {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 10;
  background: rgba(255,255,255,.18); border: none; color: #fff;
  font-size: 36px; width: 48px; height: 64px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  line-height: 1; transition: background .15s; user-select: none;
}
#gallery-prev { left: calc(8px + env(safe-area-inset-left, 0px)); }
#gallery-next { right: calc(8px + env(safe-area-inset-right, 0px)); }
#gallery-prev:hover, #gallery-next:hover { background: rgba(255,255,255,.32); }
#gallery-prev:disabled, #gallery-next:disabled { opacity: .2; cursor: default; }
#gallery-viewport {
  flex: 1; overflow: hidden; position: relative; display: flex; align-items: stretch;
}
#gallery-track {
  display: flex; height: 100%; will-change: transform;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.gallery-slide {
  flex-shrink: 0; width: 100vw; height: 100%;
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.gallery-slide img {
  max-width: 100%; max-height: 100%; object-fit: contain; display: block;
  user-select: none; -webkit-user-drag: none;
  transform-origin: center; will-change: transform;
}
.gallery-type-badge {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.75); border-radius: 8px;
  padding: 3px 9px; font-size: 11px; white-space: nowrap; pointer-events: none;
}
#gallery-dots {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 10px; flex-shrink: 0; min-height: 30px;
}
.gallery-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.3); transition: background .15s; }
.gallery-dot.active { background: #fff; }

#search-results-view,
#results {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1;
  min-width: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
}
#search-results-view {
  width: 100%;
}
#results > * { flex-shrink: 0; }
#search-results-view > * { flex-shrink: 0; }
.search-results-header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 2px 2px 4px;
}
.search-results-title {
  font-size: 15px; font-weight: 750; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-results-count {
  color: var(--muted); font-size: 12px; flex-shrink: 0;
}
.hist-card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 4px 12px;
  cursor: pointer; transition: background .1s; min-width: 0; max-width: 100%;
}
.hist-card:hover { background: var(--card2); }
.hist-card .ps-thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 4px; background: #fff; flex-shrink: 0; }
.hist-card .ps-thumb.product-image-placeholder,
.ps-thumb.product-image-placeholder,
.dc-thumb.product-image-placeholder {
  background: color-mix(in srgb, var(--card2) 68%, #fff);
}
.hist-card .hc-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start;
}
.hist-card .hc-name {
  font-size: 14px; font-weight: 600; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  white-space: normal; overflow-wrap: anywhere;
}
.hist-card .hc-meta { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-card .stale-badge {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-card .hc-right {
  align-self: stretch;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start;
  gap: 6px; flex-shrink: 0;
}
.hc-price { font-size: 14px; font-weight: 700; color: var(--green); white-space: nowrap; }
.hist-card .hc-price { margin-top: 4px; }
.hist-card .ps-heart {
  font-size: 20px; padding: 4px; background: none; border: none;
  cursor: pointer; color: var(--heart-off); line-height: 1; transition: color .15s;
}
.hist-card .ps-heart.fav { color: #ff453a; }
.hist-card .ps-remove {
  font-size: 18px; padding: 2px 4px; background: none; border: none;
  cursor: pointer; color: var(--muted); line-height: 1;
}
