/* Store checklist: neutral surfaces, one dense scroll region, fixed controls. */
#storeShoppingDialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1180px, calc(100vw - 32px));
  height: min(800px, calc(100dvh - 40px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
  box-shadow: 0 24px 75px #0008;
}
#storeShoppingDialog[open] {
  display: flex;
  flex-direction: column;
}
#storeShoppingDialog::backdrop,
.store-prompt::backdrop {
  background: #000a;
}
.store-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
}
.store-list-header h2,
.store-prompt h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}
.store-list-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}
#storeShoppingDialog .store-list-close,
.store-prompt-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: grid;
  place-items: center;
  padding: 8px;
}
#storeShoppingDialog svg,
.store-prompt svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.store-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  color: var(--muted);
  font-size: 13px;
  flex: none;
}
#storeShoppingDialog .btn,
.store-prompt .btn {
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.store-list-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.store-list-header > div:first-child {
  flex-shrink: 0;
}
.store-list-header {
  gap: 12px;
}
.store-list-header .store-list-status {
  margin: 0;
  min-width: 0;
  max-width: 460px;
  max-height: 36px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
}
.store-list-header .store-list-status:empty {
  visibility: hidden;
}
@media (max-width: 600px) {
  .store-list-header .store-list-status {
    max-width: 160px;
    font-size: 10px;
  }
  .store-list-header-actions {
    gap: 8px;
  }
}
.store-list-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 14px 0 20px;
  padding-right: 8px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #56535e #18181b;
  overscroll-behavior: contain;
}
.store-list-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.store-list-scroll::-webkit-scrollbar-track {
  background: #18181b;
  border-radius: 5px;
}
.store-list-scroll::-webkit-scrollbar-thumb {
  background: #56535e;
  border: 2px solid #18181b;
  border-radius: 5px;
}
.store-list-scroll::-webkit-scrollbar-corner {
  background: var(--surface);
}
.store-list-table {
  width: 100%;
  min-width: 850px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.store-list-table th,
.store-list-table td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}
.store-list-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  z-index: 2;
  white-space: normal;
}
.store-list-table th:nth-child(3),
.store-list-table td:nth-child(3) {
  text-align: left;
}
.store-check-col {
  width: 35px;
}
.store-grip-col {
  width: 32px;
}
.store-package-col {
  width: 176px;
}
.store-total-col {
  width: 125px;
}
.store-price-col {
  width: 122px;
}
.store-list-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #92bba1;
  cursor: pointer;
  vertical-align: middle;
}
.store-product-name,
.store-list-grip {
  border: 0;
  background: none;
  color: var(--text);
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.store-product-name {
  text-align: left;
  overflow-wrap: anywhere;
}
.store-product-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.store-list-grip {
  display: grid;
  place-items: center;
  width: 24px;
  height: 28px;
  color: var(--faint);
  touch-action: none;
  cursor: grab;
}
#storeShoppingDialog .store-list-grip svg {
  stroke-width: 3;
}
.store-list-grip:hover {
  color: var(--text);
}
.store-department th {
  text-align: left;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding-top: 20px;
  padding-bottom: 9px;
}
.store-department th span {
  margin-left: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
}
.store-list-table .is-bought .store-product-name {
  color: var(--faint);
  text-decoration: line-through;
}
.store-list-table .is-bought td:not(:first-child) {
  color: var(--faint);
}
.store-empty-department {
  display: none;
}

.store-list-table .is-drag-source {
  opacity: 0.45;
}
.store-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  flex: none;
}
.store-list-total {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.store-list-footer-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}
.store-export {
  display: flex;
  position: relative;
}
#storeShoppingDialog #storeListDownload {
  border-radius: 8px 0 0 8px;
}
#storeShoppingDialog .store-export-arrow {
  border-radius: 0 8px 8px 0;
  border-left: 0;
  width: 34px;
  padding: 7px;
  display: grid;
  place-items: center;
}
.store-export-menu {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: calc(100% + 6px);
  min-width: 160px;
  border: 1px solid var(--control);
  border-radius: 9px;
  padding: 5px;
  background: var(--raised);
  box-shadow: 0 8px 25px #0007;
}
.store-export-menu[hidden] {
  display: none;
}
.store-export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 5px;
  color: var(--text);
  background: transparent;
  padding: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.store-export-menu button:hover {
  background: var(--control);
}
.store-prompt {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  border: 1px solid var(--control);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
}
.store-prompt[open] {
  display: flex;
  flex-direction: column;
}
.store-prompt header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.store-prompt h2 {
  font-size: 18px;
}
.store-prompt-body {
  padding: 16px 20px;
  overflow: auto;
  min-height: 0;
  font-size: 13px;
  color: var(--muted);
}
.store-prompt-body p {
  margin: 0 0 14px;
  line-height: 1.6;
}
.store-prompt footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  flex: none;
}
.store-prompt label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}
.store-prompt select {
  width: 100%;
  min-height: 38px;
  padding: 8px 32px 8px 10px;
  border: 1px solid var(--control);
  border-radius: 7px;
  background-color: var(--raised);
  color: var(--text);
  font: inherit;
}
.store-keyword-list label {
  grid-template-columns: 1fr 1.8fr;
  align-items: center;
  gap: 14px;
}
.store-keyword-list label span {
  color: var(--text);
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  #storeShoppingDialog {
    width: calc(100vw - 16px);
    height: calc(100dvh - 24px);
    border-radius: 12px;
  }
  .store-list-header,
  .store-list-toolbar,
  .store-list-footer {
    padding: 12px;
  }
  .store-list-header h2 {
    font-size: 18px;
  }
  .store-list-header p {
    font-size: 11px;
  }
  .store-list-scroll {
    margin-left: 8px;
    margin-right: 6px;
    padding-right: 4px;
  }
  .store-list-table {
    min-width: 780px;
  }
  .store-list-footer {
    flex-wrap: wrap;
  }
  .store-list-footer-actions {
    margin-left: auto;
  }
  .store-list-grip {
    height: 36px;
  }
  .store-prompt footer {
    flex-wrap: wrap;
  }
}

/* Quantities lead the shopping task; prices remain secondary. */
.store-package-col {
  width: 200px;
}
.store-list-table .store-quantity {
  color: var(--text);
  white-space: nowrap;
  font-weight: 400;
}
.store-quantity strong {
  font-size: inherit;
  font-weight: 600;
}
.store-volume span {
  color: var(--muted);
  font-size: 12px;
}
.store-list-table td:nth-child(7),
.store-list-table td:nth-child(8) {
  color: var(--muted);
}
#storeShoppingDialog > .store-list-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.store-list-table input[type="checkbox"] {
  color-scheme: dark;
}
#storeShoppingDialog[aria-busy="true"] .store-list-table {
  pointer-events: none;
}

.store-count-col {
  width: 64px;
}
.store-volume {
  white-space: nowrap;
}

.store-multiply-col {
  width: 28px;
}
.store-list-table .store-multiply {
  color: var(--faint);
  text-align: center;
  padding-inline: 2px;
}
.store-list-table .store-volume,
.store-list-table thead th:nth-child(6) {
  text-align: left;
}
.store-department th {
  color: #d7af73;
}
.store-drop-line {
  position: absolute;
  z-index: 6;
  height: 2px;
  background: #c1bbd5;
  pointer-events: none;
}
.store-drop-line::before {
  content: "";
  position: absolute;
  left: -2px;
  top: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: inherit;
}
.store-drop-line[hidden] {
  display: none;
}
#storeShoppingDialog.is-dragging {
  user-select: none;
  cursor: grabbing;
}
#storeShoppingDialog.is-dragging .store-list-scroll {
  overflow-anchor: none;
  scroll-behavior: auto;
}
#storeShoppingDialog.is-dragging .store-list-grip {
  cursor: grabbing;
}
/* A phone is a shopping checklist, with one natural full-screen scroll. */
.store-mobile-controls {
  display: none;
}
@media (max-width: 600px) {
  #storeShoppingDialog[open] {
    display: block;
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scroll-padding: 54px 0 12px;
  }
  #storeShoppingDialog .store-list-header {
    position: static;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
    background: var(--surface);
  }
  #storeShoppingDialog .store-list-toolbar {
    position: static;
    padding: 10px 14px;
    font-size: 12px;
  }
  #storeShoppingDialog .store-list-toolbar .btn {
    font-size: 12px;
    min-height: 34px;
    padding: 6px 9px;
  }
  #storeShoppingDialog > .store-list-scroll {
    display: block;
    overflow: visible;
    min-height: auto;
    margin: 0;
    padding: 0 12px;
    scrollbar-gutter: auto;
  }
  #storeShoppingDialog .store-list-table {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }
  .store-list-table colgroup,
  .store-list-table thead {
    display: none;
  }
  .store-list-table tbody {
    display: block;
  }
  .store-list-table tr[data-store-product] {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 88px;
    grid-template-rows: auto auto auto;
    gap: 4px 7px;
    padding: 12px 2px;
    border-bottom: 1px solid var(--line);
    position: relative;
    -webkit-touch-callout: none;
    user-select: none;
  }
  .store-list-table tr[data-store-product] > td {
    display: block;
    min-width: 0;
    border: 0;
    padding: 0;
    line-height: 1.35;
  }
  .store-list-table tr[data-store-product] > td:first-child {
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: stretch;
  }
  .store-list-table td:first-child input {
    width: 22px;
    height: 22px;
    margin: 2px 4px 0 0;
  }
  .store-list-table tr[data-store-product] > td:nth-child(2),
  .store-list-table tr[data-store-product] > td:nth-child(5) {
    display: none;
  }
  .store-list-table tr[data-store-product] > td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }
  .store-list-table .store-product-name {
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
  }
  .store-list-table tr[data-store-product] > .store-quantity {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    text-align: right;
    padding-right: 3px;
  }
  .store-list-table .store-quantity strong {
    font-size: 16px;
    font-weight: 600;
  }
  .store-list-table .store-quantity::before {
    content: "× ";
    color: var(--faint);
    font-size: 12px;
  }
  .store-list-table tr[data-store-product] > .store-volume {
    grid-column: 2;
    grid-row: 2;
    font-size: 12px;
    color: var(--muted);
    white-space: normal;
    text-align: left;
  }
  .store-list-table tr[data-store-product] > td:nth-child(7) {
    grid-column: 2;
    grid-row: 3;
    font-size: 13px;
    color: var(--text);
    text-align: left;
  }
  .store-list-table tr[data-store-product] > td:nth-child(7)::after {
    content: " / opak.";
    font-size: 11px;
    color: var(--faint);
  }
  .store-list-table tr[data-store-product] > td:nth-child(8) {
    grid-column: 3;
    grid-row: 3;
    align-self: end;
    font-size: 11px;
    color: var(--faint);
    text-align: right;
    white-space: nowrap;
  }
  .store-list-table tr[data-store-product] > td:nth-child(8)::before {
    content: "Σ ";
  }
  .store-list-table .store-department {
    display: block;
    padding: 17px 2px 8px;
  }
  .store-list-table .store-empty-department {
    display: none;
  }
  .store-list-table .store-department th {
    display: block;
    border: 0;
    padding: 0;
    font-size: 13px;
    text-align: left;
  }
  .store-list-table .store-department th span {
    font-size: 11px;
  }
  #storeShoppingDialog .store-list-footer {
    position: static;
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
    padding: 14px 14px max(14px, env(safe-area-inset-bottom));
  }
  #storeShoppingDialog .store-list-footer-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .store-list-table tr.store-mobile-selected {
    background: var(--raised);
    box-shadow: inset 3px 0 #c1bbd5;
    touch-action: none;
  }
  #storeShoppingDialog .store-mobile-controls {
    position: absolute;
    z-index: 8;
    display: flex;
    align-items: center;
    gap: 4px;
    left: 44px;
    max-width: calc(100% - 56px);
    padding: 4px;
    background: var(--raised);
    border: 1px solid var(--control);
    border-radius: 8px;
    box-shadow: 0 4px 15px #0006;
  }
  #storeShoppingDialog .store-mobile-controls .btn {
    display: grid;
    place-items: center;
    min-width: 36px;
    min-height: 36px;
    padding: 6px 9px;
    font-size: 12px;
  }
  #storeShoppingDialog .store-mobile-controls [data-done] {
    color: #91baa0;
  }
  #storeShoppingDialog.is-dragging .store-mobile-controls {
    display: none;
  }
}
.store-separate-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.store-separate-toggle input {
  appearance: none;
  position: relative;
  width: 32px;
  height: 18px;
  flex: none;
  margin: 0;
  border: 1px solid var(--control);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.store-separate-toggle input::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform 0.15s ease;
}
.store-separate-toggle input:checked {
  background: var(--control);
}
.store-separate-toggle input:checked::before {
  transform: translateX(14px);
  background: var(--text);
}
.store-separate-toggle input:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 3px;
}
.store-list-table .store-bought-heading > td {
  padding: 16px 0 0;
  border: 0;
  text-align: left;
}
.store-bought-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 12px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--raised);
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.store-bought-toggle:hover {
  color: var(--text);
}
@media (max-width: 600px) {
  #storeShoppingDialog .store-list-toolbar {
    flex-wrap: wrap;
    gap: 6px 12px;
  }
  .store-separate-toggle {
    order: 3;
    margin-left: 0;
    min-height: 34px;
    width: 100%;
  }
  .store-list-table .store-bought-heading {
    display: block;
    padding: 14px 0 0;
  }
  .store-list-table .store-bought-heading > td {
    display: block;
    padding: 0;
  }
  .store-bought-toggle {
    min-height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .store-separate-toggle input::before {
    transition: none;
  }
}
