/* AHProfi v586: targeted mobile refinements; loaded after v585 CSS. */
@media (max-width: 760px) and (orientation: portrait) {
  /* Preserve the one-row toolbar, only a 1-2 px tap target enlargement. */
  html.ahp-layout-v497 #editorScreen .workspace-toolbar {
    gap: 6px !important;
    padding: 3px 3px 3px 2px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls { gap: 6px !important; }
  html.ahp-layout-v497 #editorScreen #mobileToolbarMoreButton {
    height: 38px !important; min-height: 38px !important; max-height: 38px !important;
    width: 36px !important; min-width: 36px !important; max-width: 36px !important;
    flex: 0 0 36px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls .zoom-toolbar-group #zoomLabel {
    width: 54px !important; min-width: 54px !important; max-width: 54px !important;
    height: 36px !important; min-height: 36px !important; max-height: 36px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls .history-toolbar-group {
    height: 38px !important; min-height: 38px !important; max-height: 38px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls .history-toolbar-group :is(#undoButton,#redoButton) {
    width: 37px !important; min-width: 37px !important; max-width: 37px !important;
    height: 36px !important; min-height: 36px !important; max-height: 36px !important;
  }
  html.ahp-layout-v497 #editorScreen #stageMinimap.toolbar-minimap.stage-minimap {
    gap: 0 !important; margin-left: auto !important;
  }
  html.ahp-layout-v497 #editorScreen #stageMinimap :is(#minimapLeft,#minimapRight) {
    flex: 0 0 21px !important;
    width: 21px !important; min-width: 21px !important; max-width: 21px !important;
  }
  /* Place the popup under its leftmost toggle, without covering the minimap. */
  html.ahp-layout-v497 #editorScreen #mobileToolbarExtras.mobile-toolbar-extras {
    left: 2px !important; right: auto !important;
  }

  /* Product card: remove forced 44px title whitespace. Keep code and stock
     immediately below the title, to the right of the product photograph. */
  html.ahp-layout-v497 #editorScreen #productList :is(.product-card,.product-card-ref) {
    --pc-img-w: 58px !important;
    display: grid !important;
    grid-template-columns: 58px minmax(0, 1fr) !important;
    grid-template-areas: "media main" "divider divider" "bottom bottom" !important;
    grid-template-rows: minmax(76px, auto) 1px 36px !important;
    gap: 4px 9px !important;
    padding: 7px 6px 8px !important;
    min-height: 132px !important; height: auto !important; max-height: none !important;
    align-content: start !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-media {
    width: 58px !important; min-width: 58px !important; max-width: 58px !important;
    height: 76px !important; min-height: 76px !important;
    align-items: center !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-thumb {
    width: 58px !important; min-width: 58px !important; max-width: 58px !important;
    height: 74px !important; min-height: 74px !important; max-height: 74px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-main {
    display: flex !important; flex-direction: column !important;
    align-items: stretch !important; justify-content: flex-start !important;
    gap: 3px !important; padding: 0 !important; margin: 0 !important;
    height: auto !important; min-height: 0 !important; max-height: none !important;
    overflow: hidden !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-title,
  html.ahp-layout-v497 #editorScreen #productList .product-title.product-title-sm,
  html.ahp-layout-v497 #editorScreen #productList .product-title.product-title-xs {
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    font-size: 11.5px !important; line-height: 1.1 !important;
    letter-spacing: 0 !important;
    height: auto !important; min-height: 0 !important; max-height: 39px !important;
    overflow: hidden !important; text-overflow: ellipsis !important;
    overflow-wrap: anywhere !important; word-break: normal !important;
    flex: 0 0 auto !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-code,.stock-line) {
    font-size: 10.5px !important; line-height: 1.13 !important;
    height: auto !important; min-height: 0 !important; max-height: 24px !important;
    margin: 0 !important; padding: 0 !important;
    overflow: hidden !important; text-overflow: ellipsis !important;
    white-space: normal !important; overflow-wrap: anywhere !important;
    flex: 0 0 auto !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .stock-line {
    font-weight: 750 !important;
  }
  html.ahp-layout-v497 #editorScreen #productList .product-bottom {
    min-height: 36px !important;
    padding-top: 0 !important; margin-top: 0 !important;
  }

  /* Overlay exists outside the product itself; it scales with the stage.
     A 60px hit area is roughly twice the old 28-32px touch target. */
  html.ahp-layout-v497 #editorScreen .canvas-remove-overlay {
    width: 60px !important; height: 60px !important;
    min-width: 60px !important; min-height: 60px !important;
    padding: 1px !important;
  }
  html.ahp-layout-v497 #editorScreen .canvas-remove-overlay .canvas-remove-icon {
    width: 100% !important; height: 100% !important;
  }
}
@media (max-width: 350px) and (orientation: portrait) {
  html.ahp-layout-v497 #editorScreen .workspace-toolbar { gap: 3px !important; }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls { gap: 4px !important; }
  html.ahp-layout-v497 #editorScreen #mobileToolbarMoreButton {
    flex: 0 0 34px !important; width: 34px !important; min-width: 34px !important; max-width: 34px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls .zoom-toolbar-group #zoomLabel {
    width: 50px !important; min-width: 50px !important; max-width: 50px !important;
  }
  html.ahp-layout-v497 #editorScreen .toolbar-main-controls .history-toolbar-group :is(#undoButton,#redoButton) {
    width: 35px !important; min-width: 35px !important; max-width: 35px !important;
  }
  html.ahp-layout-v497 #editorScreen #productList :is(.product-card,.product-card-ref) {
    grid-template-rows: minmax(92px, auto) 1px 36px !important;
    min-height: 152px !important; max-height: none !important;
  }
  html.ahp-layout-v497 #editorScreen #stageMinimap :is(#minimapLeft,#minimapRight) {
    flex: 0 0 20px !important; width: 20px !important; min-width: 20px !important; max-width: 20px !important;
  }
}
@media (max-width: 760px) and (orientation: landscape) {
  /* Keep the wider desktop-like layout, with the larger remove control. */
  html.ahp-layout-v497 #editorScreen .canvas-remove-overlay {
    width: 52px !important; height: 52px !important;
    min-width: 52px !important; min-height: 52px !important;
  }
}
