/* Native phone composition/editor, Figma 770:56870 / 770:59648.
   Text, rows and controls stay in normal flow; only images are decorative. */
@media (max-width: 430px) {
  /* [155]/[162]: min-height:100svh на страницах с малым числом вкусов
     (2–3) оставлял пустой хвост экрана до подвала — тот же баг уже
     чинили на ПК ([19].5, .set-composition-page min-height:auto).
     Убираем принудительную высоту и на планшете/телефоне: высота
     страницы теперь определяется контентом. */
  body.phone-flow :is(.set-composition-page,.edit-set-page) {
    width: 100%; min-width: 0; min-height: auto; padding: 0; overflow: visible;
  }
  /* [158]: у плашки отсутствовала боковая/верхняя тень — box-shadow не был
     задан. Значения сняты с Figma-узла 770:35967 (телефон, 24 шт): тот же
     набор inset+drop, что и на ПК/планшете, ширина плашки в макете тоже
     во весь экран — отдельный горизонтальный отступ не требуется. */
  body.phone-flow :is(.sv-head,.es-sticky-head) {
    position: sticky; top: 0; height: auto; min-height: 245px;
    padding: 89px 20px 20px; border-radius: 0 0 32px 32px;
    box-shadow: inset -4px -4px 10px #fff, inset 2px 2px 11px rgba(231,205,177,.9), 4px 4px 24px rgba(214,191,167,.45);
  }
  body.phone-flow .sv-back { position: relative; display: flex; width: fit-content; inset: auto; min-height: 16px; font-size: 14px; }
  body.phone-flow .sv-summary { position: relative; inset: auto; display: block; height: auto; margin-top: 36px; }
  /* [233]: «изменить состав набора» на телефоне — отдельная плашка на всю
     ширину под фото+описанием (Figma 770:53722: градиент, corner-radius
     80, тот же набор inset/drop теней, что и у .sv-head). Раньше ссылка
     .sv-product__edit была просто подчёркнутым текстом внутри строки с
     весом. Меняем .sv-product на грид: фото — левая колонка на 2 строки,
     кикер+название и вес — правая колонка, а .sv-product__edit (когда не
     hidden, т.е. только у сборного набора) — третья строка на всю ширину.
     display:contents у meta/bottom делает их детей прямыми items грида. */
  body.phone-flow .sv-product {
    display: grid; grid-template-columns: 84px 1fr; grid-template-rows: auto auto auto;
    column-gap: 18px; row-gap: 10px; align-items: start;
    width: 100%; height: auto; min-height: 84px;
  }
  body.phone-flow .sv-product__photo { grid-column: 1; grid-row: 1 / 3; }
  body.phone-flow .sv-product__meta { display: contents; }
  body.phone-flow .sv-product__meta > div:first-child { grid-column: 2; grid-row: 1; min-width: 0; }
  body.phone-flow .sv-product__bottom { display: contents; }
  body.phone-flow .sv-product__weight { grid-column: 2; grid-row: 2; }
  /* [80] / [19]: lower the weight line to the bottom edge of the 84px photo
     backing on both phone flows; keep the grid row and following edit action
     in normal flow. */
  body.phone-flow .sv-product__weight { transform: translateY(9.5px); }
  /* :not([hidden]) обязателен. Скрипт прячет ссылку у готовых наборов
     (page-set-composition.php: edit.hidden = item.type !== 'custom'),
     но атрибут hidden — это всего лишь display:none из стилей браузера,
     и любой явный display его перебивает. Без этой оговорки кнопка
     «изменить состав набора» показывалась на телефоне и у готовых
     наборов, где менять нечего. */
  body.phone-flow .sv-product__edit:not([hidden]) {
    grid-column: 1 / -1; grid-row: 3;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 46px; box-sizing: border-box;
    border-radius: 80px; text-decoration: none; text-align: center;
    font-size: 12px; letter-spacing: 0.03em; color: var(--c-brown-900);
    background: linear-gradient(96.6deg, #FFF6ED 15.549%, #F5E8DB 90.822%);
    box-shadow: inset -4px -4px 10px #fff, inset 2px 2px 11px rgba(231,205,177,.9), 4px 4px 24px rgba(214,191,167,.45);
  }
  body.phone-flow .set-composition-page .sv-product__edit[hidden] { display: none; }
  body.phone-flow .sv-product__title { font-size: 16px; white-space: normal; overflow-wrap: anywhere; }
  body.phone-flow .sv-product__bottom { flex-wrap: wrap; gap: 5px 12px; }
  /* [76].1/[80].1.1: фон/размер картинки набора отдаём фотографии. */
  body.phone-flow .sv-product__photo { background: transparent; }
  body.phone-flow .sv-product__photo img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; filter: none; }
  body.phone-flow .sv-ingredients { display: none; }
  body.phone-flow :is(.sv-mobile-hint,.es-hint) {
    position: relative; display: block; width: auto; min-height: 34px;
    /* [76].4/[80].1.7: избегаем висящих слов на телефоне. */
    margin: 24px 20px 0; padding: 0 12px 0 42px; font: 14px/17px var(--font-body); color: #401c0c;
    text-wrap: balance;
  }
  body.phone-flow :is(.sv-mobile-hint,.es-hint)::before {
    content: ''; position: absolute; left: 8px; top: 6px; width: 22px; height: 22px;
    background: url('../../../img/set-editor-flow-rating.svg') center / contain no-repeat;
  }
  body.phone-flow :is(.sv-grid,.es-grid,.es-add-grid) {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    grid-auto-rows: auto; gap: 0 0; width: 100%; height: auto; min-height: 0;
    padding: 0 8px; margin: 24px 0 0; overflow: visible;
  }
  body.phone-flow .set-composition-page { padding-bottom: 60px; }
  body.phone-flow :is(.sv-flavor,.es-grid .es-tile,.es-add-grid .es-tile) {
    display: grid; grid-template-rows: minmax(22px,auto) 81px 36px;
    align-content: start; justify-items: center; gap: 0;
    width: 100%; height: auto; min-height: 174px; padding: 17px 0 18px; margin: 0; overflow: visible;
  }
  body.phone-flow :is(.sv-flavor__name,.es-tile .sm-tile__name) {
    position: relative; inset: auto; width: 100%; min-width: 0; height: auto; margin: 0;
    font: 100 18px/22px var(--font-display); letter-spacing: .06em; text-align: center;
    overflow-wrap: anywhere; color: #401c0c;
  }
  body.phone-flow :is(.sv-flavor__photo,.es-tile .sm-tile__photo) {
    position: relative; inset: auto; align-self: center; width: min(154px,94%); height: 52px;
    transform: none; margin: 0; display: flex; align-items: center; justify-content: center;
  }
  body.phone-flow :is(.sv-flavor__photo,.sm-tile__photo) img { width: 100%; height: 100%; max-width: 100%; object-fit: contain; }
  /* [162]: цифра в плашке количества стояла выше центра. У цифр нет
     подстрочных элементов (descent≈0 при ascent≈8.6px на 12px), поэтому
     flex-центрирование по em-boxу шрифта (ascent 9 / descent 3) сажает
     чернильную часť глифа на ~1.3px выше геометрического центра плашки.
     box-sizing:border-box + padding-top компенсируют разницу, не двигая
     саму плашку (высота и позиция не меняются). */
  body.phone-flow .sv-flavor__qty {
    position: relative; inset: auto; width: 60px; height: 36px; font-size: 12px;
    box-sizing: border-box; padding-top: 2.5px;
  }
  body.phone-flow .es-stage { width: 100%; height: auto; margin: 0; padding-bottom: calc(76px + max(20px,env(safe-area-inset-bottom)) + 32px); box-sizing: border-box; zoom: 1; }
  body.phone-flow .es-grid { margin-bottom: 0; }
  body.phone-flow .es-stepper { position: relative; inset: auto; transform: none; height: 36px; align-self: center; }
  body.phone-flow .es-stepper__btn { position: relative; flex: 0 0 28px; width: 28px; height: 28px; font-size: 0; background: none; box-shadow: none; }
  body.phone-flow .es-stepper__btn::before { content: ''; position: absolute; top: -12px; left: -12px; width: 49px; height: 49px; background: url('../../../img/set-editor/mobile/minus.svg') center / 100% 100% no-repeat; pointer-events: none; }
  body.phone-flow .es-stepper__btn[data-plus]::before { background-image: url('../../../img/set-editor/mobile/plus.svg'); }
  body.phone-flow .es-stepper__btn::after { content: ''; position: absolute; inset: -8px; }
  body.phone-flow .es-stepper__val { display: flex; align-items: center; justify-content: center; width: 60px; min-width: 60px; height: 36px; margin: 0 -7px; padding: 0; font-size: 12px; font-weight: 500; letter-spacing: .03em; color: #b01e2b; background: linear-gradient(96.27deg,#fff6ed 15.549%,#f5e8db 90.822%); box-shadow: inset -4px -4px 10px #fff,inset 2px 2px 11px rgba(231,205,177,.9),4px 4px 12px rgba(214,191,167,.45); }
  body.phone-flow .es-grid .es-add-tile { grid-column: 1/-1; width: 100%; height: auto; min-height: 100px; padding: 32px 12px 22px; }
  body.phone-flow .es-add-btn { width: 100%; min-height: 46px; height: auto; padding: 12px 16px; letter-spacing: .03em; background: linear-gradient(119.2deg,#fff6ed 15.549%,#f5e8db 90.822%); box-shadow: inset -4px -4px 10px #fff,inset 2px 2px 11px rgba(231,205,177,.9),4px 4px 12px rgba(214,191,167,.45); }
  body.phone-flow .es-done-bar { position: fixed; inset: auto 0 0; z-index: 12; width: 100%; height: auto; min-height: 96px; margin: 0; padding: 20px 20px max(20px,env(safe-area-inset-bottom)); box-sizing: border-box; border-radius: 32px 32px 0 0; background: linear-gradient(106.45deg,#fff6ed 15.549%,#f5e8db 90.822%); box-shadow: inset -4px -4px 10px #fff,inset 2px 2px 11px rgba(231,205,177,.9),4px 4px 12px rgba(214,191,167,.45); }
  body.phone-flow .es-done { width: 100%; min-height: 56px; height: auto; font-size: 14px; letter-spacing: .03em; box-shadow: -4px -4px 4px rgba(43,3,7,.1),4px 4px 4px rgba(80,50,18,.1); }
  body.phone-flow .edit-set-page .sm-overlay { z-index: 1100; max-width: 100%; padding: 12px; overflow-y: auto; }
  body.phone-flow .sm-panel { width: 100%; min-width: 0; max-height: calc(100dvh - 24px); padding: 58px 0 20px; overflow-y: auto; }
  body.phone-flow .es-add-grid { margin: 0; }
  /* [244]: то же, что [224] — белая пилюля без красного подчёркивания. */
  body.phone-flow .es-add-flavor {
    width: 120px; min-width: 120px; max-width: 100%; height: 36px;
    padding: 0 28px; border-radius: 80px; box-sizing: border-box;
    font-family: var(--font-body); font-size: 12px; font-weight: 500;
    line-height: normal; letter-spacing: .36px; text-decoration: none; color: #b01e2b;
    background: linear-gradient(102.394deg,#fff6ed 15.549%,#f5e8db 90.822%);
    box-shadow: inset -4px -4px 10px #fff,inset 2px 2px 11px rgba(231,205,177,.9);
    filter: drop-shadow(4px 4px 12px rgba(214,191,167,.45));
  }
  body.phone-flow .es-popup__panel { width: 100%; padding: 56px 20px 32px; }
  body.phone-flow .es-popup__title { font-size: 30px; letter-spacing: .03em; }
  body.phone-flow .es-popup__text { font-size: 15px; }
  body.phone-flow .es-popup__text br { display: none; }
  body.phone-flow .set-ingredients-dialog { position: fixed; inset: 0; width: min(430px,100%); max-width: 100%; min-height: min(500px,80dvh); max-height: 90dvh; margin: auto; padding: 24px 40px 40px; border: 0; border-radius: 32px; color: #401c0c; background: linear-gradient(93deg,#fff6ed 15.549%,#f5e8db 90.822%); box-shadow: inset -4px -4px 10px #fff,inset 2px 2px 11px rgba(231,205,177,.9),4px 4px 24px rgba(214,191,167,.45); overflow-y: auto; }
  body.phone-flow .set-ingredients-dialog::backdrop { background: rgba(0,0,0,.4); backdrop-filter: blur(4px); }
  body.phone-flow .set-ingredients-dialog form { text-align: right; margin: 0 0 24px; }
  body.phone-flow .set-ingredients-dialog__close { min-width: 44px; min-height: 44px; border: 0; color: inherit; background: none; font-size: 28px; cursor: pointer; }
  body.phone-flow .set-ingredients-dialog h2 { margin: 0 0 24px; font: 100 32px/1.15 var(--font-display); letter-spacing: .06em; text-align: center; text-transform: uppercase; }
  body.phone-flow .set-ingredients-dialog p { margin: 0; font: 14px/1.35 var(--font-body); }
  body.phone-flow .sm-tile__photo[role="button"] { cursor: pointer; }
  body.phone-flow :is(.sm-tile__photo[role="button"],.sv-flavor):focus-visible { outline: 2px solid #b01e2b; outline-offset: 4px; border-radius: 8px; }
  body.phone-flow :is(.es-popup__cancel,.es-popup__size,.es-popup__ok) { min-width: 0; max-width: 100%; height: auto; min-height: 48px; padding: 12px 18px; }

  /* Mobile editor artwork is an exact photo+shadow export, not a UI screenshot.
     Its 207px column scales independently of live labels and controls. */
  body.phone-flow .edit-set-page .es-sticky-head { background: linear-gradient(96.6deg,#fff6ed 15.549%,#f5e8db 90.822%); }
  body.phone-flow .edit-set-page .sv-product__photo { position: relative; }
  body.phone-flow .edit-set-page .sv-product__photo .es-cover--figma { position: absolute; left: 4px; top: 11px; width: 82px; height: 71px; max-width: none; max-height: none; filter: none; }
  body.phone-flow .edit-set-page .es-hint { max-width: 340px; padding-right: 0; }
  body.phone-flow .edit-set-page .es-hint strong { font-weight: 500; }
  @supports (grid-template-rows: subgrid) {
    body.phone-flow .edit-set-page .es-tile { grid-row: span 3; grid-template-rows: subgrid; min-height: 0; }
  }
  body.phone-flow .edit-set-page .sm-tile__name { width: calc(100% - 12px); overflow-wrap: normal; }
  body.phone-flow .edit-set-page .sm-tile__photo { width: min(207px,100%); height: 81px; align-self: start; }
  /* Shadow is baked into the normalized source artwork; avoid adding a
     second CSS shadow on the editor page at phone widths. */
  body.phone-flow .edit-set-page .sm-tile__photo img { position: absolute; left: calc(50% + var(--art-left)); top: var(--art-top); width: var(--art-width); height: auto; max-width: none; filter: none; }
  body.phone-flow .edit-set-page .sm-tile:hover .sm-tile__photo img { transform: scale(1.02); }
  body.phone-flow .edit-set-page :is(.es-tile,.es-add-tile) { scroll-margin-top: 265px; scroll-margin-bottom: 116px; }
}

/* A tall sticky summary leaves no usable editor in landscape/short windows. */
@media (max-width: 430px) and (max-height: 600px) {
  body.phone-flow .edit-set-page .es-sticky-head { position: relative; }
  body.phone-flow .edit-set-page :is(.es-tile,.es-add-tile) { scroll-margin-top: 80px; }
  body.phone-flow .edit-set-page .es-hint { margin-top: 16px; }
  body.phone-flow .edit-set-page .es-grid { margin-top: 2px; }
}

/* A zoomed/landscape composition header must release the viewport so its
   flavors and final add link remain reachable. Match the short-height editor
   guard above; at the 568px reference, only sticky behavior changes. */
@media (max-width: 430px) and (max-height: 600px) {
  body.phone-flow .set-composition-page .sv-head { position: static; }
}
/* [77]/[80]: нормализованные вырезки sostav — единый холст на все вкусы. */
@media (max-width: 430px) {
  body.phone-flow .edit-set-page .sm-tile__photo { width: min(207px,100%); height: 81px; display: flex; align-items: center; justify-content: center; }
  body.phone-flow .edit-set-page .sm-tile__photo img { position: static; left: auto; top: auto; width: 200px; max-width: 100%; height: auto; object-fit: fill; filter: none; }
}

/* [80] p.6: the compact tablet summary already uses one column through 699px.
   Keep its ingredients and flavour grid, but place the weight at the photo's
   lower edge and the composition action on its own row, as on phone. */
/* Снят подбрейкпоинт «@media (min-width: 431px) and (max-width: 699px)»:
   он жил в телефонном файле, но целился в планшетную полосу и резал её
   надвое. Парный ему блок в tablet/pages/set-editor.css снят вместе с
   остальными при включении автоскейла (правки 17.10, п. 6) — полоса
   431–860 показывает один макет 860. */
