.shopping-bag { position: relative; }
.shopping-bag #bag-count:not([hidden]) { position:absolute; top:1px; right:0; display:grid; place-items:center; padding:1px 5px; min-width:18px; min-height:18px; border-radius:50%; background:#2d2520; color:white; font:650 12px/16px var(--type); }

dialog.store-bag {
  --bag-ink: #2d2520;
  --bag-muted: #685f56;
  --bag-line: #e6e0d7;
  --bag-field: #f6f3ed;
  --bag-enter-x: 100%;
  --bag-enter-y: 0px;
  flex-direction: column;
  align-items: stretch;
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  padding: 22px 26px max(22px, env(safe-area-inset-bottom));
  width: min(450px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border: 0;
  border-radius: 0;
  background: white;
  color: var(--bag-ink);
  font: 16px/1.35 var(--type);
  text-align: left;
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.store-bag[open] { display: flex; }
dialog.store-bag::backdrop { background: rgb(45 37 32 / 42%); }
.store-bag > * { flex: none; min-width: 0; }
.store-bag [hidden] { display: none !important; }
.store-bag button { text-transform: none; letter-spacing: normal; }
.store-bag svg { display: block; flex: none; pointer-events: none; }

.bag-heading { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.store-bag .bag-heading h2 {
  flex: 1;
  margin: 0;
  color: var(--bag-ink);
  font: 700 23px/28px var(--type);
  letter-spacing: -.025em;
  text-transform: none;
}
.store-bag .bag-heading h2:focus { outline: none; }
.bag-close, .bag-stepper button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.bag-close { flex: none; background: #f3f1ed; font: 400 22px/1 var(--type); }
.bag-add { min-height: 44px; color: var(--bag-ink); font-weight: 650; }
.bag-body, .bag-items, .bag-preferences { display: grid; }
.bag-item-copy b, .bag-stepper output { font-variant-numeric: tabular-nums; }
.bag-brand { padding: 12px 0; border-bottom: 1px solid var(--bag-line); font: 650 15px/20px var(--type); }
.bag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--bag-line);
}
.bag-image { width: 54px; height: 54px; flex: none; border-radius: 8px; background: #f8f4ea; object-fit: cover; }
.bag-image[src$="box-2.svg"], .bag-image[src$="box-4.svg"] { object-fit: none; }
.bag-item-copy, .bag-preference-copy { display: grid; gap: 1px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bag-item-copy strong { font: 700 16px/21px var(--type); }
.bag-item-copy span { color: var(--bag-muted); font: 450 13px/18px var(--type); }
.bag-item-copy b { font: 600 14px/19px var(--type); }
.bag-stepper { display: flex; flex: none; align-items: center; border-radius: 99px; background: #f4f2ee; }
.bag-stepper button { font: 550 17px/1 var(--type); }
.bag-stepper button:disabled { color: #857e77; }
.bag-stepper output { min-width: 1ch; text-align: center; font: 650 14px/19px var(--type); }
.bag-stepper button:focus-visible { outline-offset: -3px; }

.bag-preference, .bag-note {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 9px;
  color: var(--bag-ink);
  text-align: left;
}
.bag-preference { min-height: 54px; justify-content: space-between; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--bag-line); }
.bag-preference small { color: var(--bag-muted); font: 500 12px/17px var(--type); }
.bag-preference strong { font: 600 15px/20px var(--type); white-space: pre-line; }
.bag-note-region { padding-top: 12px; }
.bag-note { min-height: 48px; padding: 0 12px; border-radius: 8px; background: var(--bag-field); font: 600 14px/19px var(--type); }
.bag-note span { display: inline-flex; align-items: center; gap: 9px; }
.bag-note > :last-child { margin-inline-start: auto; }
.bag-note-editor { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--bag-field); }
.bag-note-editor label { font: 650 14px/19px var(--type); }
.store-bag .bag-note-editor textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  padding: 10px;
  border: 1px solid #887866;
  border-radius: 6px;
  background: white;
  color: var(--bag-ink);
  font: 450 14px/20px var(--type);
  resize: vertical;
}
.bag-note-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 16px; }
.bag-note-actions button { min-width: 44px; min-height: 44px; font: 650 14px/19px var(--type); }
.bag-note-save { padding: 0 14px; border-radius: 8px; background: var(--bag-ink); color: white; }

.bag-bottom { display: grid; gap: 8px; padding-top: 10px; }
.bag-total { display: flex; min-height: 32px; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; }
.bag-total strong:last-child { text-align: right; font-size: 18px; }
.bag-primary {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border-radius: 99px;
  background: var(--bag-ink);
  color: white;
  font: 650 16px/21px var(--type);
  text-align: center;
}
.bag-primary:disabled { background: #eae6de; color: #665d52; }
.store-bag .bag-empty, .store-bag .bag-notice { margin: 0; padding-block: 12px; font-size: 15px; line-height: 22px; }

@media (max-width: 760px) {
  dialog.store-bag {
    --bag-enter-x: 0px;
    --bag-enter-y: 100%;
    inset: auto 0 0;
    width: 100%;
    height: auto;
    max-height: 92dvh;
    padding: 12px 18px max(22px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  .store-bag .bag-note-editor textarea { font-size: 16px; }
}
@media (max-width: 359px) {
  dialog.store-bag { padding-inline: 14px; }
  .bag-item { gap: 8px; }
  .bag-image { width: 48px; height: 48px; }
}
@media (hover: hover) {
  .bag-add:hover, .bag-note-cancel:hover { text-decoration: underline; text-underline-offset: .18em; }
  .bag-stepper button:enabled:hover, .bag-close:hover { background-color: #eae6de; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.store-bag {
    transform: translate(var(--bag-enter-x), var(--bag-enter-y));
    transition: transform 150ms cubic-bezier(.4,0,.8,.35),
      display 150ms allow-discrete, overlay 150ms allow-discrete;
  }
  dialog.store-bag[open] {
    transform: translate(0, 0);
    transition-duration: 240ms;
    transition-timing-function: cubic-bezier(.2,.8,.2,1);
  }
  dialog.store-bag::backdrop {
    opacity: 0;
    transition: opacity 150ms ease-out, display 150ms allow-discrete, overlay 150ms allow-discrete;
  }
  dialog.store-bag[open]::backdrop { opacity: 1; transition-duration: 240ms; }
  dialog.store-bag:not([open]), dialog.store-bag:not([open])::backdrop { pointer-events: none; }
  @starting-style {
    dialog.store-bag[open] { transform: translate(var(--bag-enter-x), var(--bag-enter-y)); }
    dialog.store-bag[open]::backdrop { opacity: 0; }
  }
  .bag-note-reveal { animation: bag-note-enter 140ms ease-out; }
}
@keyframes bag-note-enter {
  from { transform: translateY(3px); opacity: .4; }
  to { transform: translateY(0); opacity: 1; }
}
