/* Weighted template layout. Engine-owned fields, order and visibility stay intact.
   Structural roles work with text weights, selects and optional summary wrappers. */
body.nd-menu #options[data-nd-kind="weight"]:not(#\9) {
  --pp-width: 480px;
}
body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input):not(#\9) {
  --pp-width: 960px;
}
body.nd-menu #options[data-nd-kind="weight"] .modal-body > .row:has(> .dish_img):not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .modal-body > .row:has(> div > img):not(#\9) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin: 0 0 12px;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .modal-body > .row:has(> .dish_img) > div:not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .modal-body > .row:has(> div > img) > div:not(#\9) {
  width: auto;
  min-width: 0;
  max-width: none;
  flex: none;
  padding: 0;
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .dish_img img:not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .modal-body > .row > div > img:not(#\9) {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 300px;
  object-fit: cover;
}
body.nd-menu #options[data-nd-kind="weight"] .dish_img .desc:not(#\9) {
  margin-top: 14px;
  margin-bottom: 8px;
}
body.nd-menu #options[data-nd-kind="weight"] .desc :is(h2, h3):not(#\9) {
  font-size: 1rem;
  line-height: 1.5;
}
body.nd-menu #options[data-nd-kind="weight"] .description > .row:not(#\9) {
  margin: 0;
  gap: 6px;
}
body.nd-menu #options[data-nd-kind="weight"] .description > .row > div:not(#\9) {
  flex: 0 0 100%;
  max-width: 100%;
  padding: 0;
}
/* Optional enclosing panel: do not require the Site's .shadow-wrapper name. */
body.nd-menu #options[data-nd-kind="weight"] div:has(> .row .unit_weight):has(> .price_wrap):not(#\9) {
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 18px;
  background: #fff;
  box-shadow: none;
}
/* The nearest row with separate weight/quantity cells, independent of col-* sizes. */
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div .unit_weight):has(> div .quantity2):not(:has(.dish_img)):not(:has(.wrapper)):not(#\9) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div .unit_weight):has(> div .quantity2):not(:has(.dish_img)):not(:has(.wrapper)) > div:not(#\9) {
  width: auto;
  max-width: none;
  padding: 0;
  border: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div > .unit_weight):not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div > .quantity2):not(#\9) {
  display: block;
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div > .unit_weight) > div:not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .row:has(> div > .quantity2) > div:not(#\9) {
  width: 100%;
  max-width: none;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .unit_weight:not(#\9) {
  min-height: 48px;
  display: flex;
  align-items: center;
  overflow-wrap: anywhere;
}
body.nd-menu #options[data-nd-kind="weight"] .unit_weight select:not(#\9),
body.nd-menu #options[data-nd-kind="weight"] .quantity2:has(> input[name="quantity"]):not(#\9) {
  width: 100%;
  min-width: 0;
}
/* Keep the heading and both engine totals together, even without .total_weight. */
body.nd-menu #options[data-nd-kind="weight"] .price_wrap:not(#\9) {
  margin: 16px 0 0 !important;
  padding: 12px !important;
  border-radius: 12px;
  background: var(--pp-sunk);
}
body.nd-menu #options[data-nd-kind="weight"] .price_wrap > .row:not(#\9) {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .price_wrap > .row > div:not(#\9) {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .price_wrap > .row > div:has(> h4):not(#\9) {
  flex-basis: 100%;
}
body.nd-menu #options[data-nd-kind="weight"] .price_wrap h4:not(#\9) {
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .price_wrap .price:not(#\9) {
  display: block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
/* Only placement of choice groups/tiles: their appearance belongs to the shell. */
body.nd-menu #options[data-nd-kind="weight"] .wrapper:not(#\9) {
  margin: 16px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
body.nd-menu #options[data-nd-kind="weight"] .wrapper > .option_control:not(#\9) {
  flex: 0 0 100%;
  max-width: 100%;
  min-width: 0;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .option_control > .row:has(> label):not(#\9) {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .option_control > .row > label:not(#\9) {
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 0 !important;
}
body.nd-menu #options[data-nd-kind="weight"] .modal-body > div:has(> input[name="comments"]):not(#\9) {
  clear: both;
  margin-top: 12px;
}
@media (min-width: 861px) {
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> .dish_img):not(#\9),
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> div > img):not(#\9) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    direction: inherit; /* Grid line 1 is inline-start: right in RTL, left in LTR. */
  }
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> .dish_img) > div:not(#\9),
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> div > img) > div:not(#\9) {
    grid-column: 2;
    grid-row: 1;
  }
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> .dish_img) > .dish_img:not(#\9),
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-body > .row:has(> div > img) > div:has(> img):not(#\9) {
    grid-column: 1;
    grid-row: 1;
  }
  body.nd-menu #options[data-nd-kind="weight"] .modal-dialog.modal-lg:not(#\9) {
    max-width: min(800px, calc(100vw - 56px));
  }
  body.nd-menu #options[data-nd-kind="weight"] .modal-dialog.modal-md:not(#\9) {
    max-width: min(500px, calc(100vw - 56px));
  }
}
@media (max-width: 767.98px) {
  body.nd-menu #options[data-nd-kind="weight"] .wrapper:not(#\9) {
    max-height: none;
    overflow: visible;
  }
  body.nd-menu #options[data-nd-kind="weight"]:has(.modal-body > .row > div:not(.dish_img) > .desc) .dish_img .desc:not(#\9) {
    display: none !important; /* templates supply their own phone description in the other cell */
  }
}

/* In the compact window, put the existing name before the existing description.
   display:contents changes boxes only; engine ancestry and reading selectors stay intact. */
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .modal-body > .row:has(> .dish_img):not(#\9) {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .modal-body > .row:has(> .dish_img) > div:not(#\9) {
  display: contents;
}
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .dish_img > img:not(#\9) {
  order: 0;
}
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .modal-body > .row:has(> .dish_img) > div > .description:not(#\9) {
  order: 1;
}
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .modal-body > .row:has(> .dish_img) > div > .desc:not(#\9) {
  order: 2;
}
body.nd-menu #options[data-nd-kind="weight"]:not(:has(.wrapper input)) .modal-body > .row:has(> .dish_img) > div > :not(img, .description, .desc, .nd-weight-price-tag):not(#\9) {
  order: 3;
}

body.nd-menu #options[data-nd-kind="weight"] .option_control:not(:has(img)) > .row:has(> label):not(#\9) {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
body.nd-menu #options[data-nd-kind="weight"] .option_control:not(:has(img)) > .row > label:not(#\9) {
  flex: 1 1 auto;
}

body.nd-menu #options[data-nd-kind="weight"] .description:not(#\9) {
  margin: 0;
  padding: 0;
}
body.nd-menu #options[data-nd-kind="weight"] :is(.discounts, .wrapper):empty:not(#\9) {
  display: none;
}

@media (max-width: 767.98px) {
  /* A literal weight range needs more room than one half-width field. */
  body.nd-menu #options[data-nd-kind="weight"] .row:has(> div .unit_weight):has(> div .quantity2):has(option[value*="-"]):not(:has(.dish_img)):not(:has(.wrapper)):not(#\9) {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (min-width: 861px) {
  /* A deliberately medium template stays compact even when it has choices. */
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-dialog.modal-md .modal-body > .row:has(> .dish_img):not(#\9),
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-dialog.modal-md .modal-body > .row:has(> div > img):not(#\9) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-dialog.modal-md .modal-body > .row:has(> .dish_img) > div:not(#\9),
  body.nd-menu #options[data-nd-kind="weight"]:has(.wrapper input) .modal-dialog.modal-md .modal-body > .row:has(> div > img) > div:not(#\9) {
    grid-column: auto;
    grid-row: auto;
  }
}
/* Some templates have direct summary children rather than .price_wrap. */
body.nd-menu #options[data-nd-kind="weight"] .row:has(> .weight):has(> .price):not(#\9) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--pp-sunk);
}
body.nd-menu #options[data-nd-kind="weight"] .row:has(> .weight):has(> .price) > h4:not(#\9) {
  flex: 0 0 100%;
  margin: 0;
}
body.nd-menu #options[data-nd-kind="weight"] .row:has(> .weight):has(> .price) > :is(.weight, .price):not(#\9) {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
}

/* The existing per-weight label; never copied or recalculated. */
body.nd-menu #options[data-nd-kind="weight"].nd-weight-choices .nd-weight-media:not(#\9) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-media > img:not(#\9) { order: 0; }
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-media > .desc:not(#\9) { order: 2; }
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-media > .nd-weight-price-tag:not(#\9) {
  position: relative;
  z-index: 1;
  order: 1;
  align-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  width: max-content;
  max-width: 100%;
  margin: -19px auto 0 !important;
  padding: 8px 18px !important;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--nd-on-primary, #fff);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.4;
}
body.nd-menu #options[data-nd-kind="weight"]:not(.nd-weight-choices) .modal-body > .row > div > .nd-weight-price-tag:not(#\9) {
  order: 0;
  margin-top: -33px !important;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-price-tag small:not(#\9) { color: inherit; font-size: .78em; }
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select:not(#\9) { position: relative; }
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select select:not(#\9) {
  appearance: none;
  -webkit-appearance: none;
  padding-inline: 13px 36px;
  cursor: pointer;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select:not(#\9)::after {
  content: "";
  position: absolute;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  background: currentColor;
  opacity: .6;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select select:active:not(#\9) { background-color: #f2f2f2; border-color: var(--primary); }
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select select:focus-visible:not(#\9) { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 767.98px) {
  body.nd-menu #options[data-nd-kind="weight"] .option_control > .row:has(> label):not(#\9) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Readable single-column fallback when relational selectors are unavailable. */
body.nd-menu #options[data-nd-kind="weight"].nd-pp-no-has .modal-body .row:not(#\9) { display: block; margin: 0; }
body.nd-menu #options[data-nd-kind="weight"].nd-pp-no-has .modal-body .row > div:not(#\9) {
  width: 100%; max-width: 100%; min-width: 0; padding-inline: 0;
}
body.nd-menu #options[data-nd-kind="weight"].nd-pp-no-has .option_control > .row:not(#\9) {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
body.nd-menu #options[data-nd-kind="weight"].nd-pp-no-has .nd-weight-media:not(#\9) { display: flex; flex-direction: column; }
body.nd-menu #options[data-nd-kind="weight"].nd-pp-no-has .nd-weight-media > .nd-weight-price-tag:not(#\9) { order: 1; margin-top: -19px !important; }
body.nd-menu #options[data-nd-kind="weight"].nd-weight-choices .nd-weight-media > img:not(#\9) {
  aspect-ratio: 3 / 2;
  max-height: none;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-media > img:not(#\9) { margin: 0; }
body.nd-menu #options[data-nd-kind="weight"] .wrapper > .option_control:not(#\9) {
  border-radius: 14px;
  padding: 12px;
}
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-media > :not(img, .nd-weight-price-tag):not(#\9) { order: 2; }
body.nd-menu #options[data-nd-kind="weight"] .price_wrap:not(#\9) { border: 1px solid #e1e1e1; }
/* Native pickers may release :active as their OS menu opens; focus keeps the pressed-field feedback. */
body.nd-menu #options[data-nd-kind="weight"] .nd-weight-select select:focus:not(#\9) {
  background-color: #f2f2f2;
  border-color: var(--primary);
}
