.product-sheet {
  position: fixed;
  z-index: 100;
  inset: var(--sheet-viewport-top, 0px) 0 auto;
  width: min(100%, 390px);
  max-width: none;
  height: var(--sheet-viewport-height, 100dvh);
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.product-sheet:not([open]) {
  display: none;
}

.product-sheet::backdrop {
  background: rgb(0 0 0 / 28%);
}

.product-sheet[open]::backdrop {
  animation: product-sheet-backdrop-in 360ms ease-out both;
}

.product-sheet__surface {
  --sheet-drag-y: 0px;

  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  max-height: calc(var(--sheet-viewport-height, 100dvh) - 80px);
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -14px 40px rgb(0 0 0 / 14%);
  transform: translate3d(0, var(--sheet-drag-y), 0);
}

.product-sheet.is-opening .product-sheet__surface {
  animation: product-sheet-in 420ms cubic-bezier(.22, 1, .36, 1) both;
}

.product-sheet.is-dragging .product-sheet__surface {
  animation: none;
  transition: none;
  will-change: transform;
}

.product-sheet.is-settling .product-sheet__surface {
  animation: none;
  transition: transform 180ms cubic-bezier(.22, 1, .36, 1);
}

.product-sheet.is-closing .product-sheet__surface {
  animation: product-sheet-out 260ms cubic-bezier(.4, 0, 1, 1) both;
  pointer-events: none;
}

.product-sheet.is-closing::backdrop {
  animation: product-sheet-backdrop-out 260ms ease both;
}

.product-sheet__handle-zone {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: 28px;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.product-sheet__handle {
  width: 38px;
  height: 4px;
  background: #d8d6d1;
  border-radius: 999px;
}

.product-sheet__scroll {
  max-height: calc(var(--sheet-viewport-height, 100dvh) - 80px);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}

.product-sheet__scroll::-webkit-scrollbar {
  display: none;
}

.product-sheet__media {
  position: relative;
  height: 252px;
  margin-top: 0;
  overflow: hidden;
  background: var(--color-soft, #f7f6f3);
}

.product-sheet__media > img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 12px;
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
}

.product-sheet__placeholder {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #9a8674;
  background: var(--color-soft, #f7f6f3);
}

.product-sheet__placeholder .icon {
  width: 64px;
  height: 64px;
  stroke-width: 1.4;
}

.product-sheet__close {
  position: absolute;
  z-index: 2;
  top: 36px;
  right: 14px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  color: #171717;
  background: rgb(255 255 255 / 90%);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 5px 18px rgb(0 0 0 / 10%);
  line-height: 0;
  backdrop-filter: blur(10px);
}

.product-sheet__close .icon {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.product-sheet__badge {
  position: absolute;
  top: 40px;
  left: 16px;
  padding: 7px 11px;
  color: var(--color-brand);
  background: rgb(255 255 255 / 92%);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.product-sheet__content {
  display: grid;
  gap: 26px;
  padding: 20px 16px 24px;
}

.product-sheet__header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 31px;
  letter-spacing: -.035em;
}

.product-sheet__header p {
  margin: 8px 0 0;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 19px;
}

.product-sheet__section {
  display: grid;
  gap: 11px;
}

.product-sheet__section h3,
.product-sheet__comment label {
  margin: 0;
  font-size: 16px;
  font-weight: 760;
  line-height: 20px;
}

.product-sheet__section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.product-sheet__section-heading small {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 620;
}

.product-sheet__segments {
  display: grid;
  min-height: 48px;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--control-surface);
  border-radius: 14px;
}

.product-sheet__segments button {
  min-height: 44px;
  padding: 0 14px;
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
}

.product-sheet__segments button.is-active {
  color: var(--control-ink);
  background: #fff;
  box-shadow: 0 2px 8px rgb(25 24 23 / 7%);
}

.product-sheet__sizes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.product-sheet__sizes button,
.product-sheet__addon {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  color: var(--control-ink);
  background: #fff;
  border: 1px solid var(--control-border);
  border-radius: 14px;
}

.product-sheet__sizes button {
  display: grid;
}

.product-sheet__sizes button.is-active,
.product-sheet__addon.is-active {
  border-color: var(--control-ink);
  box-shadow: inset 0 0 0 1px var(--control-ink);
}

.product-sheet__sizes span,
.product-sheet__addon > span {
  font-size: 13px;
  font-weight: 700;
}

.product-sheet__sizes small,
.product-sheet__addon small {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 620;
}

.product-sheet__addons {
  display: grid;
  gap: 8px;
}

.product-sheet__sauces {
  display: grid;
  gap: 8px;
}

.product-sheet__segments button > span,
.product-sheet__segments button > small {
  display: block;
}

.product-sheet__segments button > small {
  margin-top: 2px;
  font-size: 9px;
  line-height: 11px;
}

.product-sheet__segments button.is-unavailable,
.product-sheet__sauce.is-unavailable,
.product-sheet__addon.is-unavailable {
  opacity: 0.58;
}

.product-sheet__sauce {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  color: var(--control-ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--control-border);
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
}

.product-sheet__sauce > span {
  display: grid;
  gap: 3px;
}

.product-sheet__sauce small {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 620;
  white-space: nowrap;
}

.product-sheet__sauce.is-active {
  border-color: var(--control-ink);
  box-shadow: inset 0 0 0 1px var(--control-ink);
}

.product-sheet__addon {
  min-height: 52px;
}

.product-sheet__addon > span {
  display: grid;
  gap: 3px;
}

.product-sheet__addon-quantity {
  display: grid;
  grid-template-columns: 40px 28px 40px;
  align-items: center;
  flex: 0 0 auto;
}

.product-sheet__addon-quantity button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  color: var(--control-ink);
  background: var(--control-surface);
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.product-sheet__addon-quantity button:disabled {
  color: var(--color-muted);
  opacity: 0.45;
}

.product-sheet__addon-quantity output {
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.product-sheet__comment textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 13px 14px;
  color: var(--control-ink);
  background: var(--control-surface);
  border: 1px solid transparent;
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  line-height: 20px;
}

.product-sheet__comment textarea:focus {
  background: #fff;
  border-color: var(--control-ink);
  outline: 0;
}

.product-sheet__purchase {
  position: absolute;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  min-height: 92px;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 96%);
  border-top: 1px solid var(--color-line);
  box-shadow: 0 -10px 24px rgb(25 24 23 / 5%);
  backdrop-filter: blur(12px);
}

.product-sheet__purchase--unavailable {
  grid-template-columns: 1fr;
}

.product-sheet__unavailable {
  display: grid;
  min-height: 56px;
  place-items: center;
  color: var(--color-muted);
  background: var(--color-soft);
  border: 1px solid var(--color-line);
  border-radius: 16px;
  font-size: 15px;
  font-weight: 760;
}

.product-sheet__total {
  display: grid;
  min-width: 76px;
}

.product-sheet__total span {
  color: var(--color-muted);
  font-size: 10px;
}

.product-sheet__total strong {
  margin-top: 2px;
  font-size: 19px;
  line-height: 23px;
  white-space: nowrap;
}

.product-sheet__add {
  min-height: 56px;
  padding: 0 18px;
  color: #fff;
  background: var(--color-brand);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 9px 20px rgb(217 37 27 / 18%);
  font-size: 15px;
  font-weight: 760;
}

.product-sheet__quantity {
  display: grid;
  min-height: 56px;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  overflow: hidden;
  color: var(--control-ink);
  background: var(--control-surface);
  border: 1px solid var(--control-border);
  border-radius: 16px;
}

.product-sheet__quantity button {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--control-ink);
  background: transparent;
  border: 0;
}

.product-sheet__quantity output {
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Desktop keeps its normal document layout. Mobile additionally freezes the
   body: overflow alone can still let Safari pan the root behind a dialog. */
html.sheet-open {
  overflow: hidden;
}

html.sheet-mobile-open {
  height: 100%;
  overscroll-behavior: none;
}

html.sheet-mobile-open body {
  position: fixed;
  top: var(--sheet-scroll-y, 0px);
  right: 0;
  left: 0;
  width: 100%;
}

@media (max-width: 1023px) {
  .product-sheet.is-dragging .product-sheet__surface {
    user-select: none;
  }
}

@keyframes product-sheet-in {
  from {
    transform: translate3d(0, 100%, 0);
  }

  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes product-sheet-out {
  from {
    transform: translate3d(0, var(--sheet-drag-y), 0);
  }

  to {
    transform: translate3d(0, 100%, 0);
  }
}

@keyframes product-sheet-backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes product-sheet-backdrop-out {
  to {
    opacity: 0;
  }
}

@media (hover: hover) and (pointer: fine) {
  .product-sheet__sizes button:hover,
  .product-sheet__addon:hover,
  .product-sheet__sauce:hover {
    border-color: #b8b5af;
  }
}

@media (min-width: 1024px) {
  .product-sheet {
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 32px;
  }

  .product-sheet[open] {
    display: grid;
    place-items: center;
  }

  .product-sheet__surface {
    position: static;
    display: grid;
    width: min(1080px, calc(100vw - 64px));
    max-height: min(840px, calc(100dvh - 64px));
    grid-template-columns: minmax(380px, .92fr) minmax(440px, 1.08fr);
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 28px;
    box-shadow: 0 26px 80px rgb(0 0 0 / 22%);
    transform: none;
    animation: product-sheet-desktop-in 200ms cubic-bezier(.22, 1, .36, 1) both;
  }

  .product-sheet.is-closing .product-sheet__surface {
    animation: product-sheet-desktop-out 180ms ease-in both;
  }

  .product-sheet__handle-zone {
    display: none;
  }

  .product-sheet__scroll {
    display: contents;
  }

  .product-sheet__media {
    height: auto;
    min-height: 600px;
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .product-sheet__media > img {
    padding: 36px;
  }

  .product-sheet__close {
    top: 18px;
    right: 18px;
  }

  .product-sheet__badge {
    top: 20px;
    left: 20px;
  }

  .product-sheet__content {
    min-height: 0;
    grid-column: 2;
    grid-row: 1;
    overflow-y: auto;
    padding: 34px 34px 28px;
    scrollbar-width: thin;
    scrollbar-color: #d8d6d1 transparent;
  }

  .product-sheet__header {
    padding-right: 48px;
  }

  .product-sheet__header h2 {
    font-size: 32px;
    line-height: 38px;
  }

  .product-sheet__purchase {
    position: static;
    grid-column: 2;
    grid-row: 2;
    padding: 16px 34px;
  }

  @keyframes product-sheet-desktop-in {
    from {
      opacity: 0;
      transform: scale(.985) translateY(8px);
    }

    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  @keyframes product-sheet-desktop-out {
    to {
      opacity: 0;
      transform: scale(.99) translateY(6px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-sheet.is-opening .product-sheet__surface,
  .product-sheet__surface {
    animation-duration: .01ms;
  }

  .product-sheet.is-settling .product-sheet__surface {
    transition-duration: .01ms;
  }

  .product-sheet[open]::backdrop,
  .product-sheet.is-closing .product-sheet__surface,
  .product-sheet.is-closing::backdrop {
    animation-duration: .01ms;
  }
}
